summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/ossl_ssl.c')
-rw-r--r--ext/openssl/ossl_ssl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 5876946..a180ff2 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1744,7 +1744,13 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
if (ssl_started(ssl)) {
for (;;){
- nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
+ int num = RSTRING_LENINT(str);
+
+ /* SSL_write(3ssl) manpage states num == 0 is undefined */
+ if (num == 0)
+ goto end;
+
+ nwrite = SSL_write(ssl, RSTRING_PTR(str), num);
switch(ssl_get_error(ssl, nwrite)){
case SSL_ERROR_NONE:
goto end;