Fix error handling in heartbeat processing
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 6 Nov 2017 10:27:41 +0000 (11:27 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Tue, 7 Nov 2017 14:09:16 +0000 (15:09 +0100)
Fixes: #4590

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4681)

ssl/s3_pkt.c

index 04212c51e726d72c938b34dcc6b02eabaa9e34ed..b9145684304176902d95df6c6e04a4ff93522c9d 100644 (file)
@@ -1324,10 +1324,16 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
         }
 #ifndef OPENSSL_NO_HEARTBEATS
         else if (rr->type == TLS1_RT_HEARTBEAT) {
-            tls1_process_heartbeat(s);
+            i = tls1_process_heartbeat(s);
+
+            if (i < 0)
+                return i;
 
-            /* Exit and notify application to read again */
             rr->length = 0;
+            if (s->mode & SSL_MODE_AUTO_RETRY)
+                goto start;
+
+            /* Exit and notify application to read again */
             s->rwstate = SSL_READING;
             BIO_clear_retry_flags(SSL_get_rbio(s));
             BIO_set_retry_read(SSL_get_rbio(s));