Make sure we free and cleanse the pms value in all code paths
authorMatt Caswell <matt@openssl.org>
Mon, 30 Jan 2017 19:36:51 +0000 (19:36 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 30 Jan 2017 22:58:53 +0000 (22:58 +0000)
Otherwise we get a memory leak.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2326)

ssl/s3_lib.c

index c4d43526bd743064401c65db5cf6562aca7ad57c..936a30136310d822701d92ce5cfe2eb9ea744e8d 100644 (file)
@@ -4118,10 +4118,8 @@ int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret)
 
             rv = rv && tls13_generate_handshake_secret(s, pms, pmslen);
         } else {
-            /* Generate master secret and discard premaster */
-            rv = ssl_generate_master_secret(s, pms, pmslen, 1);
+            rv = ssl_generate_master_secret(s, pms, pmslen, 0);
         }
-        pms = NULL;
     } else {
         /* Save premaster secret */
         s->s3->tmp.pms = pms;