]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Ensure that memory allocated for the ticket is freed
authorMatt Caswell <matt@openssl.org>
Tue, 15 Mar 2016 11:38:56 +0000 (11:38 +0000)
committerMatt Caswell <matt@openssl.org>
Fri, 18 Mar 2016 11:59:11 +0000 (11:59 +0000)
If a call to EVP_DecryptUpdate fails then a memory leak could occur.
Ensure that the memory is freed appropriately.

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/t1_lib.c

index 2e9b65b3fdcecc56ca90060234f64e9874f787ee..090f93ef62cc033ea6fd1a6c03986fa90a4a5fac 100644 (file)
@@ -2321,8 +2321,10 @@ static int tls_decrypt_ticket(SSL *s, const unsigned char *etick,
     p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx);
     eticklen -= 16 + EVP_CIPHER_CTX_iv_length(&ctx);
     sdec = OPENSSL_malloc(eticklen);
-    if (!sdec || EVP_DecryptUpdate(&ctx, sdec, &slen, p, eticklen) <= 0) {
+    if (sdec == NULL
+            || EVP_DecryptUpdate(&ctx, sdec, &slen, p, eticklen) <= 0) {
         EVP_CIPHER_CTX_cleanup(&ctx);
+        OPENSSL_free(sdec);
         return -1;
     }
     if (EVP_DecryptFinal(&ctx, sdec + slen, &mlen) <= 0) {