Fix a mem leak on error in the PSK code
authorMatt Caswell <matt@openssl.org>
Mon, 27 Aug 2018 13:52:09 +0000 (14:52 +0100)
committerPaul Yang <yang.yang@baishancloud.com>
Thu, 30 Aug 2018 01:50:29 +0000 (09:50 +0800)
Thanks to @fangang190 for reporting this issue.

Fixes #7060

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
(Merged from https://github.com/openssl/openssl/pull/7065)

ssl/s3_lib.c

index 5ecbc3c5543acafe9fbf6cbad6012d8e82310a25..7713f767b2d309035eb98167c35ba04ba429037a 100644 (file)
@@ -4621,6 +4621,7 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
         if (!s->method->ssl3_enc->generate_master_secret(s,
                     s->session->master_key,pskpms, pskpmslen,
                     &s->session->master_key_length)) {
+            OPENSSL_clear_free(pskpms, pskpmslen);
             /* SSLfatal() already called */
             goto err;
         }