summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-07-20 15:45:30 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-07-20 15:45:30 +0000
commite794f7db702266a47bff8d593c7ff67fcdceaff6 (patch)
treec6c1ea8e223e6c4e3a51caa62b37bbf50ba86ff7 /lib
parent4fa76482fa90560532374f5988e4fa9d1b5b29ef (diff)
Various memory leaks upon error or unchecked allocations.
ok doug@
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/hmac/hm_ameth.c17
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;