Improve the early data sanity check in SSL_do_handshake()
authorMatt Caswell <matt@openssl.org>
Fri, 24 Feb 2017 17:08:41 +0000 (17:08 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 2 Mar 2017 17:44:16 +0000 (17:44 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2737)

ssl/ssl_lib.c

index b675c2eeadca335093234bbfa76509ae79c45082..3bcb6e1643fb4c9f78d990fcaadb5c3a7c394a99 100644 (file)
@@ -3232,9 +3232,15 @@ int SSL_do_handshake(SSL *s)
         return -1;
     }
 
-    if (s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY
-            || s->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY)
-        return -1;
+    if (s->early_data_state != SSL_EARLY_DATA_NONE
+            && s->early_data_state != SSL_EARLY_DATA_FINISHED_WRITING
+            && s->early_data_state != SSL_EARLY_DATA_FINISHED_READING
+            && s->early_data_state != SSL_EARLY_DATA_ACCEPTING
+            && s->early_data_state != SSL_EARLY_DATA_CONNECTING) {
+        SSLerr(SSL_F_SSL_WRITE_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        return 0;
+    }
+
 
     s->method->ssl_renegotiate_check(s, 0);