diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-20 15:45:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-20 15:45:30 +0000 |
commit | e794f7db702266a47bff8d593c7ff67fcdceaff6 (patch) | |
tree | c6c1ea8e223e6c4e3a51caa62b37bbf50ba86ff7 /lib | |
parent | 4fa76482fa90560532374f5988e4fa9d1b5b29ef (diff) |
Various memory leaks upon error or unchecked allocations.
ok doug@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/hmac/hm_ameth.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/libcrypto/hmac/hm_ameth.c b/lib/libcrypto/hmac/hm_ameth.c index f4fa6f4bc34..da3471c4fd4 100644 --- a/lib/libcrypto/hmac/hm_ameth.c +++ b/lib/libcrypto/hmac/hm_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hm_ameth.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: hm_ameth.c,v 1.9 2015/07/20 15:45:29 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2007. */ @@ -112,10 +112,17 @@ old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); - if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) - return 0; - EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); + if (os == NULL) + goto err; + if (ASN1_OCTET_STRING_set(os, *pder, derlen) == 0) + goto err; + if (EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os) == 0) + goto err; return 1; + +err: + ASN1_OCTET_STRING_free(os); + return 0; } static int @@ -127,6 +134,8 @@ old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) if (pder) { if (!*pder) { *pder = malloc(os->length); + if (*pder == NULL) + return -1; inc = 0; } else inc = 1; |