diff options
| author | logan <> | 2014-06-28 18:25:24 +0000 |
|---|---|---|
| committer | logan <> | 2014-06-28 18:25:24 +0000 |
| commit | f18925b701a050f5ccf4d42a9bfda83bdbc6335c (patch) | |
| tree | 7c2675aa8955536b704c47f046f3730761dc1fb4 /src | |
| parent | fab309eb9787bf465ee62a5c88281566e09dbaac (diff) | |
| download | openbsd-f18925b701a050f5ccf4d42a9bfda83bdbc6335c.tar.gz openbsd-f18925b701a050f5ccf4d42a9bfda83bdbc6335c.tar.bz2 openbsd-f18925b701a050f5ccf4d42a9bfda83bdbc6335c.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.c | 8 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/x509/x509_att.c | 8 |
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 | ||
| 349 | err: | 352 | err: |
| 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 | ||
| 349 | err: | 352 | err: |
| 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 | } |
