if log fails, avoid pms getting double free
authorRich Salz <rsalz@openssl.org>
Mon, 24 Apr 2017 13:41:51 +0000 (09:41 -0400)
committerRich Salz <rsalz@openssl.org>
Mon, 24 Apr 2017 13:41:51 +0000 (09:41 -0400)
doing the pms assignment after log is successful

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3278)

ssl/statem/statem_clnt.c

index 8207dde..a8bb566 100644 (file)
@@ -2854,13 +2854,13 @@ static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)
         goto err;
     }
 
-    s->s3->tmp.pms = pms;
-    s->s3->tmp.pmslen = pmslen;
-
     /* Log the premaster secret, if logging is enabled. */
     if (!ssl_log_rsa_client_key_exchange(s, encdata, enclen, pms, pmslen))
         goto err;
 
+    s->s3->tmp.pms = pms;
+    s->s3->tmp.pmslen = pmslen;
+
     return 1;
  err:
     OPENSSL_clear_free(pms, pmslen);