diff options
author | miod <> | 2015-02-14 12:43:07 +0000 |
---|---|---|
committer | miod <> | 2015-02-14 12:43:07 +0000 |
commit | 297b0d4a8bf51772b3f0e84123424a8a85e55eab (patch) | |
tree | 57a9e3eb3014ef86834a30a199e0838e0f74d7c9 /src/lib/libcrypto/pkcs12/p12_decr.c | |
parent | d18f9324ae82e670faf7e01361779f8b667bce93 (diff) | |
download | openbsd-297b0d4a8bf51772b3f0e84123424a8a85e55eab.tar.gz openbsd-297b0d4a8bf51772b3f0e84123424a8a85e55eab.tar.bz2 openbsd-297b0d4a8bf51772b3f0e84123424a8a85e55eab.zip |
Try and fix a bunch of memory leaks upon error;
ok tedu@ about 7 months ago and I was sitting upon this diff for no reason
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_decr.c')
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_decr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c index b6bd508bf1..13be237b4c 100644 --- a/src/lib/libcrypto/pkcs12/p12_decr.c +++ b/src/lib/libcrypto/pkcs12/p12_decr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: p12_decr.c,v 1.13 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: p12_decr.c,v 1.14 2015/02/14 12:43:07 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -166,19 +166,23 @@ PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, | |||
166 | if (!in) { | 166 | if (!in) { |
167 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, | 167 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, |
168 | PKCS12_R_ENCODE_ERROR); | 168 | PKCS12_R_ENCODE_ERROR); |
169 | return NULL; | 169 | goto err; |
170 | } | 170 | } |
171 | if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, | 171 | if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, |
172 | &oct->length, 1)) { | 172 | &oct->length, 1)) { |
173 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, | 173 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, |
174 | PKCS12_R_ENCRYPT_ERROR); | 174 | PKCS12_R_ENCRYPT_ERROR); |
175 | free(in); | 175 | goto err; |
176 | return NULL; | ||
177 | } | 176 | } |
178 | if (zbuf) | 177 | if (zbuf) |
179 | OPENSSL_cleanse(in, inlen); | 178 | OPENSSL_cleanse(in, inlen); |
180 | free(in); | 179 | free(in); |
181 | return oct; | 180 | return oct; |
181 | |||
182 | err: | ||
183 | free(in); | ||
184 | M_ASN1_OCTET_STRING_free(oct); | ||
185 | return NULL; | ||
182 | } | 186 | } |
183 | 187 | ||
184 | IMPLEMENT_PKCS12_STACK_OF(PKCS7) | 188 | IMPLEMENT_PKCS12_STACK_OF(PKCS7) |