Additional check to handle BAD SSL_write retry
authorRich Salz <rsalz@openssl.org>
Tue, 11 Apr 2017 16:11:34 +0000 (12:11 -0400)
committerRich Salz <rsalz@openssl.org>
Tue, 11 Apr 2017 16:11:34 +0000 (12:11 -0400)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3123)

ssl/record/rec_layer_s3.c

index 2f105a4c4d27408f7fe2551f250620964a3a7994..c533bbd73aef6de00081f32753de329bb26de404 100644 (file)
@@ -368,7 +368,8 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int 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 ((unsigned int)len < s->rlayer.wnum) {
+    if (((unsigned int)len < s->rlayer.wnum) 
+        || ((wb->left != 0) && ((unsigned int)len < (s->rlayer.wnum + s->rlayer.wpend_tot)))) {
         SSLerr(SSL_F_SSL3_WRITE_BYTES, SSL_R_BAD_LENGTH);
         return -1;
     }