aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2017-07-10 17:20:42 -0400
committerAndreas Schneider <asn@cryptomilk.org>2018-06-29 17:08:54 +0200
commite2b48dc662d3434a66525981fd6dab8eb72e9495 (patch)
tree14d9eba179eb0398330ba922ddc74bbabb8dc42b
parent1a5b6ac4727f83c7650aa3d527b098175d8f4147 (diff)
downloadlibssh-e2b48dc662d3434a66525981fd6dab8eb72e9495.tar.gz
libssh-e2b48dc662d3434a66525981fd6dab8eb72e9495.tar.xz
libssh-e2b48dc662d3434a66525981fd6dab8eb72e9495.zip
libcrypto: fix resource leak in hmac_final
Fix a resource leak in `hmac_final`: say `HMAC_CTX_free` instead of `HMAC_CTX_reset`. This matches the error handling as done in `hmac_init`. Introduced with cf1e808e2ffa1f26644fb5d2cb82a919f323deba. The problem is reproducible running the `pkd_hello` test with: valgrind --leak-check=full ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_default Resolves https://red.libssh.org/issues/252. Cherry-picked from a64ddff3fe16f938b99130d2a4928cda33cfcd36 Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/libcrypto.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c
index bcd5ba15..cd3acdb1 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -366,7 +366,8 @@ void hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, unsigned int *len) {
HMAC_Final(ctx,hashmacbuf,len);
#ifndef OLD_CRYPTO
- HMAC_CTX_reset(ctx);
+ HMAC_CTX_free(ctx);
+ ctx = NULL;
#else
HMAC_cleanup(ctx);
#endif