Additional check to handle BAD SSL_write retry
[openssl.git] / ssl / record / rec_layer_s3.c
index 562b9e454be7a0671ca6d482d87172ab3de53249..14c6778ae61edc82a5e2b898848b27344d261e46 100644 (file)
@@ -356,7 +356,8 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, size_t len,
      * promptly send beyond the end of the users buffer ... so we trap and
      * report the error in a way the user will notice
      */
-    if (len < s->rlayer.wnum) {
+    if ((len < s->rlayer.wnum) 
+        || ((wb->left != 0) && (len < (s->rlayer.wnum + s->rlayer.wpend_tot)))) {
         SSLerr(SSL_F_SSL3_WRITE_BYTES, SSL_R_BAD_LENGTH);
         return -1;
     }