summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlogan <>2014-06-28 18:25:24 +0000
committerlogan <>2014-06-28 18:25:24 +0000
commit9c105697aa791bb1154f5737fbe2349e602bb5b7 (patch)
tree7c2675aa8955536b704c47f046f3730761dc1fb4 /src
parent24dbdf7997e422b5d6039e76fcbe78c88f8afee5 (diff)
downloadopenbsd-9c105697aa791bb1154f5737fbe2349e602bb5b7.tar.gz
openbsd-9c105697aa791bb1154f5737fbe2349e602bb5b7.tar.bz2
openbsd-9c105697aa791bb1154f5737fbe2349e602bb5b7.zip
Fix a memory leak and another one that occurs in the error paths.
(Thanks to Brent Cook) OK from tedu@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_att.c8
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_att.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
index f2668d189d..bbbeba50ac 100644
--- a/src/lib/libcrypto/x509/x509_att.c
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_att.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ 1/* $OpenBSD: x509_att.c,v 1.9 2014/06/28 18:25:24 logan Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -333,8 +333,11 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
333 * at least one value but some types use and zero length SET and 333 * at least one value but some types use and zero length SET and
334 * require this. 334 * require this.
335 */ 335 */
336 if (attrtype == 0) 336 if (attrtype == 0) {
337 ASN1_STRING_free(stmp);
337 return 1; 338 return 1;
339 }
340
338 if (!(ttmp = ASN1_TYPE_new())) 341 if (!(ttmp = ASN1_TYPE_new()))
339 goto err; 342 goto err;
340 if ((len == -1) && !(attrtype & MBSTRING_FLAG)) { 343 if ((len == -1) && !(attrtype & MBSTRING_FLAG)) {
@@ -347,6 +350,7 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
347 return 1; 350 return 1;
348 351
349err: 352err:
353 ASN1_STRING_free(stmp);
350 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); 354 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
351 return 0; 355 return 0;
352} 356}
diff --git a/src/lib/libssl/src/crypto/x509/x509_att.c b/src/lib/libssl/src/crypto/x509/x509_att.c
index f2668d189d..bbbeba50ac 100644
--- a/src/lib/libssl/src/crypto/x509/x509_att.c
+++ b/src/lib/libssl/src/crypto/x509/x509_att.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_att.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ 1/* $OpenBSD: x509_att.c,v 1.9 2014/06/28 18:25:24 logan Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -333,8 +333,11 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
333 * at least one value but some types use and zero length SET and 333 * at least one value but some types use and zero length SET and
334 * require this. 334 * require this.
335 */ 335 */
336 if (attrtype == 0) 336 if (attrtype == 0) {
337 ASN1_STRING_free(stmp);
337 return 1; 338 return 1;
339 }
340
338 if (!(ttmp = ASN1_TYPE_new())) 341 if (!(ttmp = ASN1_TYPE_new()))
339 goto err; 342 goto err;
340 if ((len == -1) && !(attrtype & MBSTRING_FLAG)) { 343 if ((len == -1) && !(attrtype & MBSTRING_FLAG)) {
@@ -347,6 +350,7 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
347 return 1; 350 return 1;
348 351
349err: 352err:
353 ASN1_STRING_free(stmp);
350 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); 354 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
351 return 0; 355 return 0;
352} 356}