From 9620aea0e79b41aa466ace8e322f9b7bb7005a4c Mon Sep 17 00:00:00 2001 From: Anirudh Ramachandran Date: Fri, 7 Apr 2017 11:58:27 -0700 Subject: [PATCH] Fix leak in HMAC_CTX_free compat API Summary: D4406876 replaced EVP_MD_CTX and HMAC_CTX on the stack with heap-allocated versions. We omitted the _cleanup functions thinking those didn't actually free anything, but turns out HMAC_CTX_cleanup internally calls EVP_MD_CTX_cleanup which OPENSSL_frees a bunch of stuff. Reviewed By: yfeldblum Differential Revision: D4850388 fbshipit-source-id: 4ef1413a4105f3638140e4d12aeae64afe43f099 --- folly/portability/OpenSSL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/folly/portability/OpenSSL.cpp b/folly/portability/OpenSSL.cpp index 6c1f66dc..43a4692b 100644 --- a/folly/portability/OpenSSL.cpp +++ b/folly/portability/OpenSSL.cpp @@ -70,6 +70,7 @@ HMAC_CTX* HMAC_CTX_new(void) { void HMAC_CTX_free(HMAC_CTX* ctx) { if (ctx) { + HMAC_CTX_cleanup(ctx); OPENSSL_free(ctx); } } -- 2.34.1