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

ssl/s3_pkt.c

index 39cdbaf8983c7b717218924b1a70c26168d478e7..0290c991d8101d56613a099c5005507df279b4b0 100644 (file)
@@ -670,7 +670,7 @@ 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 (len < tot) {
+    if ((len < tot) || ((wb->left != 0) && (len < (tot + s->s3->wpend_tot)))) {
         SSLerr(SSL_F_SSL3_WRITE_BYTES, SSL_R_BAD_LENGTH);
         return (-1);
     }