summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2015-02-14 15:11:22 +0000
committermiod <>2015-02-14 15:11:22 +0000
commit3d65de15766e3a723255b724e69359a9711bc115 (patch)
treef65a7860fd6c9cdca1672448da54018952b9e7ea
parenta50ada071c44ffc00ef0d3ed509d23aa02005dd5 (diff)
downloadopenbsd-3d65de15766e3a723255b724e69359a9711bc115.tar.gz
openbsd-3d65de15766e3a723255b724e69359a9711bc115.tar.bz2
openbsd-3d65de15766e3a723255b724e69359a9711bc115.zip
Coverity CID 21733 (unchecked allocation), 78823 (leak on error).
ok doug@ jsing@
-rw-r--r--src/lib/libcrypto/dsa/dsa_ameth.c7
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_ameth.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c
index d4c8b111a8..b9ee49f055 100644
--- a/src/lib/libcrypto/dsa/dsa_ameth.c
+++ b/src/lib/libcrypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.16 2015/02/11 04:05:14 beck Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.17 2015/02/14 15:11:22 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 2006. 3 * project 2006.
4 */ 4 */
@@ -143,9 +143,14 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
143 ASN1_STRING *str; 143 ASN1_STRING *str;
144 144
145 str = ASN1_STRING_new(); 145 str = ASN1_STRING_new();
146 if (str == NULL) {
147 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
148 goto err;
149 }
146 str->length = i2d_DSAparams(dsa, &str->data); 150 str->length = i2d_DSAparams(dsa, &str->data);
147 if (str->length <= 0) { 151 if (str->length <= 0) {
148 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); 152 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
153 ASN1_STRING_free(str);
149 goto err; 154 goto err;
150 } 155 }
151 pval = str; 156 pval = str;
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_ameth.c b/src/lib/libssl/src/crypto/dsa/dsa_ameth.c
index d4c8b111a8..b9ee49f055 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_ameth.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.16 2015/02/11 04:05:14 beck Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.17 2015/02/14 15:11:22 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 2006. 3 * project 2006.
4 */ 4 */
@@ -143,9 +143,14 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
143 ASN1_STRING *str; 143 ASN1_STRING *str;
144 144
145 str = ASN1_STRING_new(); 145 str = ASN1_STRING_new();
146 if (str == NULL) {
147 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
148 goto err;
149 }
146 str->length = i2d_DSAparams(dsa, &str->data); 150 str->length = i2d_DSAparams(dsa, &str->data);
147 if (str->length <= 0) { 151 if (str->length <= 0) {
148 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); 152 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
153 ASN1_STRING_free(str);
149 goto err; 154 goto err;
150 } 155 }
151 pval = str; 156 pval = str;