summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2015-02-08 22:20:18 +0000
committermiod <>2015-02-08 22:20:18 +0000
commit4410e930dcdbf09c5404c19a2f8a8b695aae8746 (patch)
tree65ee060fa04d8aa1dfd7500c7c351b1b76f57228
parent705f4ae838e975ff98c0985c32bc9d2b86d6b715 (diff)
downloadopenbsd-4410e930dcdbf09c5404c19a2f8a8b695aae8746.tar.gz
openbsd-4410e930dcdbf09c5404c19a2f8a8b695aae8746.tar.bz2
openbsd-4410e930dcdbf09c5404c19a2f8a8b695aae8746.zip
Check memory allocation results in EVP_PBE_alg_add_type().
ok doug@ jsing@
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c13
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_pbe.c13
2 files changed, 20 insertions, 6 deletions
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index ac593549e5..0787e2dc94 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pbe.c,v 1.22 2014/10/28 05:46:56 miod Exp $ */ 1/* $OpenBSD: evp_pbe.c,v 1.23 2015/02/08 22:20:18 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 */
@@ -203,9 +203,16 @@ EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
203{ 203{
204 EVP_PBE_CTL *pbe_tmp; 204 EVP_PBE_CTL *pbe_tmp;
205 205
206 if (!pbe_algs) 206 if (pbe_algs == NULL) {
207 pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); 207 pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
208 if (!(pbe_tmp = (EVP_PBE_CTL*)malloc(sizeof(EVP_PBE_CTL)))) { 208 if (pbe_algs == NULL) {
209 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE,
210 ERR_R_MALLOC_FAILURE);
211 return 0;
212 }
213 }
214 pbe_tmp = malloc(sizeof(EVP_PBE_CTL));
215 if (pbe_tmp == NULL) {
209 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); 216 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
210 return 0; 217 return 0;
211 } 218 }
diff --git a/src/lib/libssl/src/crypto/evp/evp_pbe.c b/src/lib/libssl/src/crypto/evp/evp_pbe.c
index ac593549e5..0787e2dc94 100644
--- a/src/lib/libssl/src/crypto/evp/evp_pbe.c
+++ b/src/lib/libssl/src/crypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pbe.c,v 1.22 2014/10/28 05:46:56 miod Exp $ */ 1/* $OpenBSD: evp_pbe.c,v 1.23 2015/02/08 22:20:18 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 */
@@ -203,9 +203,16 @@ EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
203{ 203{
204 EVP_PBE_CTL *pbe_tmp; 204 EVP_PBE_CTL *pbe_tmp;
205 205
206 if (!pbe_algs) 206 if (pbe_algs == NULL) {
207 pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); 207 pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
208 if (!(pbe_tmp = (EVP_PBE_CTL*)malloc(sizeof(EVP_PBE_CTL)))) { 208 if (pbe_algs == NULL) {
209 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE,
210 ERR_R_MALLOC_FAILURE);
211 return 0;
212 }
213 }
214 pbe_tmp = malloc(sizeof(EVP_PBE_CTL));
215 if (pbe_tmp == NULL) {
209 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); 216 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
210 return 0; 217 return 0;
211 } 218 }