Fix the SSL_stateless() return code
[openssl.git] / ssl / ssl_lib.c
index b0d016a03d0083bf2589fd2d59f251a5d2735caf..f68031e57167d8dc295ac9b7dfdbbb611d5a923c 100644 (file)
@@ -590,6 +590,7 @@ int SSL_clear(SSL *s)
     OPENSSL_free(s->psksession_id);
     s->psksession_id = NULL;
     s->psksession_id_len = 0;
+    s->hello_retry_request = 0;
 
     s->error = 0;
     s->hit = 0;
@@ -5302,7 +5303,7 @@ int SSL_stateless(SSL *s)
 
     /* Ensure there is no state left over from a previous invocation */
     if (!SSL_clear(s))
-        return -1;
+        return 0;
 
     ERR_clear_error();
 
@@ -5310,5 +5311,8 @@ int SSL_stateless(SSL *s)
     ret = SSL_accept(s);
     s->s3->flags &= ~TLS1_FLAGS_STATELESS;
 
-    return ret;
+    if (ret > 0 && s->ext.cookieok)
+        return 1;
+
+    return 0;
 }