summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2015-07-20 15:45:29 +0000
committermiod <>2015-07-20 15:45:29 +0000
commite9c572c56a6b9de69b6b334e56df19d11d0304ef (patch)
treee8bf8b4d4f4dcfc6e840220e577ae56ba36fabf4
parent5ed4f59b4f0ac21a8c65bf523684fae22f188d90 (diff)
downloadopenbsd-e9c572c56a6b9de69b6b334e56df19d11d0304ef.tar.gz
openbsd-e9c572c56a6b9de69b6b334e56df19d11d0304ef.tar.bz2
openbsd-e9c572c56a6b9de69b6b334e56df19d11d0304ef.zip
Various memory leaks upon error or unchecked allocations.
ok doug@
-rw-r--r--src/lib/libcrypto/hmac/hm_ameth.c17
-rw-r--r--src/lib/libssl/src/crypto/hmac/hm_ameth.c17
2 files changed, 26 insertions, 8 deletions
diff --git a/src/lib/libcrypto/hmac/hm_ameth.c b/src/lib/libcrypto/hmac/hm_ameth.c
index f4fa6f4bc3..da3471c4fd 100644
--- a/src/lib/libcrypto/hmac/hm_ameth.c
+++ b/src/lib/libcrypto/hmac/hm_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hm_ameth.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: hm_ameth.c,v 1.9 2015/07/20 15:45:29 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2007. 3 * project 2007.
4 */ 4 */
@@ -112,10 +112,17 @@ old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
112 ASN1_OCTET_STRING *os; 112 ASN1_OCTET_STRING *os;
113 113
114 os = ASN1_OCTET_STRING_new(); 114 os = ASN1_OCTET_STRING_new();
115 if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) 115 if (os == NULL)
116 return 0; 116 goto err;
117 EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); 117 if (ASN1_OCTET_STRING_set(os, *pder, derlen) == 0)
118 goto err;
119 if (EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os) == 0)
120 goto err;
118 return 1; 121 return 1;
122
123err:
124 ASN1_OCTET_STRING_free(os);
125 return 0;
119} 126}
120 127
121static int 128static int
@@ -127,6 +134,8 @@ old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)
127 if (pder) { 134 if (pder) {
128 if (!*pder) { 135 if (!*pder) {
129 *pder = malloc(os->length); 136 *pder = malloc(os->length);
137 if (*pder == NULL)
138 return -1;
130 inc = 0; 139 inc = 0;
131 } else 140 } else
132 inc = 1; 141 inc = 1;
diff --git a/src/lib/libssl/src/crypto/hmac/hm_ameth.c b/src/lib/libssl/src/crypto/hmac/hm_ameth.c
index f4fa6f4bc3..da3471c4fd 100644
--- a/src/lib/libssl/src/crypto/hmac/hm_ameth.c
+++ b/src/lib/libssl/src/crypto/hmac/hm_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hm_ameth.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: hm_ameth.c,v 1.9 2015/07/20 15:45:29 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2007. 3 * project 2007.
4 */ 4 */
@@ -112,10 +112,17 @@ old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
112 ASN1_OCTET_STRING *os; 112 ASN1_OCTET_STRING *os;
113 113
114 os = ASN1_OCTET_STRING_new(); 114 os = ASN1_OCTET_STRING_new();
115 if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) 115 if (os == NULL)
116 return 0; 116 goto err;
117 EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); 117 if (ASN1_OCTET_STRING_set(os, *pder, derlen) == 0)
118 goto err;
119 if (EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os) == 0)
120 goto err;
118 return 1; 121 return 1;
122
123err:
124 ASN1_OCTET_STRING_free(os);
125 return 0;
119} 126}
120 127
121static int 128static int
@@ -127,6 +134,8 @@ old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)
127 if (pder) { 134 if (pder) {
128 if (!*pder) { 135 if (!*pder) {
129 *pder = malloc(os->length); 136 *pder = malloc(os->length);
137 if (*pder == NULL)
138 return -1;
130 inc = 0; 139 inc = 0;
131 } else 140 } else
132 inc = 1; 141 inc = 1;