summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeck <>2014-07-22 02:21:20 +0000
committerbeck <>2014-07-22 02:21:20 +0000
commitc4e3191290f7dc034878e8c9eee2f395db280afd (patch)
tree98cdda658409d8b250bb1c60e392a61894be842a /src
parent2384810741e4764a84e9c140c697eb7f1ff264c0 (diff)
downloadopenbsd-c4e3191290f7dc034878e8c9eee2f395db280afd.tar.gz
openbsd-c4e3191290f7dc034878e8c9eee2f395db280afd.tar.bz2
openbsd-c4e3191290f7dc034878e8c9eee2f395db280afd.zip
Kill a bunch more BUF_strdup's - these are converted to have a check for
NULL before an intrinsic strdup. ok miod@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c6
-rw-r--r--src/lib/libcrypto/cryptlib.c4
-rw-r--r--src/lib/libcrypto/srp/srp_vfy.c7
-rw-r--r--src/lib/libcrypto/store/str_meth.c6
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c6
-rw-r--r--src/lib/libcrypto/x509/x509_vpm.c6
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_mod.c6
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.c4
-rw-r--r--src/lib/libssl/src/crypto/srp/srp_vfy.c7
-rw-r--r--src/lib/libssl/src/crypto/store/str_meth.c6
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c6
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vpm.c6
12 files changed, 40 insertions, 30 deletions
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index c4c429497c..4363f297c7 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: conf_mod.c,v 1.24 2014/07/13 16:03:09 beck Exp $ */ 1/* $OpenBSD: conf_mod.c,v 1.25 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -283,6 +283,8 @@ module_add(DSO *dso, const char *name, conf_init_func *ifunc,
283{ 283{
284 CONF_MODULE *tmod = NULL; 284 CONF_MODULE *tmod = NULL;
285 285
286 if (name == NULL)
287 return NULL;
286 if (supported_modules == NULL) 288 if (supported_modules == NULL)
287 supported_modules = sk_CONF_MODULE_new_null(); 289 supported_modules = sk_CONF_MODULE_new_null();
288 if (supported_modules == NULL) 290 if (supported_modules == NULL)
@@ -292,7 +294,7 @@ module_add(DSO *dso, const char *name, conf_init_func *ifunc,
292 return NULL; 294 return NULL;
293 295
294 tmod->dso = dso; 296 tmod->dso = dso;
295 tmod->name = BUF_strdup(name); 297 tmod->name = strdup(name);
296 tmod->init = ifunc; 298 tmod->init = ifunc;
297 tmod->finish = ffunc; 299 tmod->finish = ffunc;
298 tmod->links = 0; 300 tmod->links = 0;
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 6a75d9568c..000f76a6a2 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cryptlib.c,v 1.32 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: cryptlib.c,v 1.33 2014/07/22 02:21:20 beck Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -210,7 +210,7 @@ CRYPTO_get_new_lockid(char *name)
210 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); 210 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
211 return (0); 211 return (0);
212 } 212 }
213 if ((str = BUF_strdup(name)) == NULL) { 213 if (name == NULL || (str = strdup(name)) == NULL) {
214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); 214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
215 return (0); 215 return (0);
216 } 216 }
diff --git a/src/lib/libcrypto/srp/srp_vfy.c b/src/lib/libcrypto/srp/srp_vfy.c
index 6de843527d..0b2a3415c2 100644
--- a/src/lib/libcrypto/srp/srp_vfy.c
+++ b/src/lib/libcrypto/srp/srp_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: srp_vfy.c,v 1.8 2014/07/13 16:03:10 beck Exp $ */ 1/* $OpenBSD: srp_vfy.c,v 1.9 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with 2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with
3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr) 3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr)
4 * for the EdelKey project and contributed to the OpenSSL project 2004. 4 * for the EdelKey project and contributed to the OpenSSL project 2004.
@@ -291,7 +291,7 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch)
291 if (newgN == NULL) 291 if (newgN == NULL)
292 return NULL; 292 return NULL;
293 293
294 if ((newgN->b64_bn = BUF_strdup(ch)) == NULL) 294 if (ch == NULL || (newgN->b64_bn = strdup(ch)) == NULL)
295 goto err; 295 goto err;
296 296
297 len = t_fromb64(tmp, ch); 297 len = t_fromb64(tmp, ch);
@@ -402,7 +402,8 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
402 if ((gN = malloc(sizeof(SRP_gN))) == NULL) 402 if ((gN = malloc(sizeof(SRP_gN))) == NULL)
403 goto err; 403 goto err;
404 404
405 if (!(gN->id = BUF_strdup(pp[DB_srpid])) 405 if ( (pp[DB_srpid] == NULL)
406 || !(gN->id = strdup(pp[DB_srpid]))
406 || !(gN->N = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpverifier])) 407 || !(gN->N = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpverifier]))
407 || !(gN->g = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpsalt])) 408 || !(gN->g = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpsalt]))
408 || sk_SRP_gN_insert(SRP_gN_tab,gN,0) == 0) 409 || sk_SRP_gN_insert(SRP_gN_tab,gN,0) == 0)
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c
index b3d4f9cc37..9d7c5ed98d 100644
--- a/src/lib/libcrypto/store/str_meth.c
+++ b/src/lib/libcrypto/store/str_meth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: str_meth.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: str_meth.c,v 1.7 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003. 3 * project 2003.
4 */ 4 */
@@ -65,8 +65,8 @@ STORE_create_method(char *name)
65{ 65{
66 STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); 66 STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD));
67 67
68 if (store_method) 68 if (store_method && name)
69 store_method->name = BUF_strdup(name); 69 store_method->name = strdup(name);
70 70
71 return store_method; 71 return store_method;
72} 72}
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 4fabcd9909..baf86d7635 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ui_lib.c,v 1.27 2014/07/13 16:03:10 beck Exp $ */ 1/* $OpenBSD: ui_lib.c,v 1.28 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -585,8 +585,8 @@ UI_create_method(char *name)
585{ 585{
586 UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); 586 UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD));
587 587
588 if (ui_method) 588 if (ui_method && name)
589 ui_method->name = BUF_strdup(name); 589 ui_method->name = strdup(name);
590 590
591 return ui_method; 591 return ui_method;
592} 592}
diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c
index ec35267298..4ad2350222 100644
--- a/src/lib/libcrypto/x509/x509_vpm.c
+++ b/src/lib/libcrypto/x509/x509_vpm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vpm.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: x509_vpm.c,v 1.10 2014/07/22 02:21:20 beck 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 2004. 3 * project 2004.
4 */ 4 */
@@ -213,7 +213,9 @@ int
213X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) 213X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
214{ 214{
215 free(param->name); 215 free(param->name);
216 param->name = BUF_strdup(name); 216 if (name == NULL)
217 return 1;
218 param->name = strdup(name);
217 if (param->name) 219 if (param->name)
218 return 1; 220 return 1;
219 return 0; 221 return 0;
diff --git a/src/lib/libssl/src/crypto/conf/conf_mod.c b/src/lib/libssl/src/crypto/conf/conf_mod.c
index c4c429497c..4363f297c7 100644
--- a/src/lib/libssl/src/crypto/conf/conf_mod.c
+++ b/src/lib/libssl/src/crypto/conf/conf_mod.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: conf_mod.c,v 1.24 2014/07/13 16:03:09 beck Exp $ */ 1/* $OpenBSD: conf_mod.c,v 1.25 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -283,6 +283,8 @@ module_add(DSO *dso, const char *name, conf_init_func *ifunc,
283{ 283{
284 CONF_MODULE *tmod = NULL; 284 CONF_MODULE *tmod = NULL;
285 285
286 if (name == NULL)
287 return NULL;
286 if (supported_modules == NULL) 288 if (supported_modules == NULL)
287 supported_modules = sk_CONF_MODULE_new_null(); 289 supported_modules = sk_CONF_MODULE_new_null();
288 if (supported_modules == NULL) 290 if (supported_modules == NULL)
@@ -292,7 +294,7 @@ module_add(DSO *dso, const char *name, conf_init_func *ifunc,
292 return NULL; 294 return NULL;
293 295
294 tmod->dso = dso; 296 tmod->dso = dso;
295 tmod->name = BUF_strdup(name); 297 tmod->name = strdup(name);
296 tmod->init = ifunc; 298 tmod->init = ifunc;
297 tmod->finish = ffunc; 299 tmod->finish = ffunc;
298 tmod->links = 0; 300 tmod->links = 0;
diff --git a/src/lib/libssl/src/crypto/cryptlib.c b/src/lib/libssl/src/crypto/cryptlib.c
index 6a75d9568c..000f76a6a2 100644
--- a/src/lib/libssl/src/crypto/cryptlib.c
+++ b/src/lib/libssl/src/crypto/cryptlib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cryptlib.c,v 1.32 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: cryptlib.c,v 1.33 2014/07/22 02:21:20 beck Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -210,7 +210,7 @@ CRYPTO_get_new_lockid(char *name)
210 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); 210 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
211 return (0); 211 return (0);
212 } 212 }
213 if ((str = BUF_strdup(name)) == NULL) { 213 if (name == NULL || (str = strdup(name)) == NULL) {
214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); 214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
215 return (0); 215 return (0);
216 } 216 }
diff --git a/src/lib/libssl/src/crypto/srp/srp_vfy.c b/src/lib/libssl/src/crypto/srp/srp_vfy.c
index 6de843527d..0b2a3415c2 100644
--- a/src/lib/libssl/src/crypto/srp/srp_vfy.c
+++ b/src/lib/libssl/src/crypto/srp/srp_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: srp_vfy.c,v 1.8 2014/07/13 16:03:10 beck Exp $ */ 1/* $OpenBSD: srp_vfy.c,v 1.9 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with 2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with
3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr) 3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr)
4 * for the EdelKey project and contributed to the OpenSSL project 2004. 4 * for the EdelKey project and contributed to the OpenSSL project 2004.
@@ -291,7 +291,7 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch)
291 if (newgN == NULL) 291 if (newgN == NULL)
292 return NULL; 292 return NULL;
293 293
294 if ((newgN->b64_bn = BUF_strdup(ch)) == NULL) 294 if (ch == NULL || (newgN->b64_bn = strdup(ch)) == NULL)
295 goto err; 295 goto err;
296 296
297 len = t_fromb64(tmp, ch); 297 len = t_fromb64(tmp, ch);
@@ -402,7 +402,8 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
402 if ((gN = malloc(sizeof(SRP_gN))) == NULL) 402 if ((gN = malloc(sizeof(SRP_gN))) == NULL)
403 goto err; 403 goto err;
404 404
405 if (!(gN->id = BUF_strdup(pp[DB_srpid])) 405 if ( (pp[DB_srpid] == NULL)
406 || !(gN->id = strdup(pp[DB_srpid]))
406 || !(gN->N = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpverifier])) 407 || !(gN->N = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpverifier]))
407 || !(gN->g = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpsalt])) 408 || !(gN->g = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpsalt]))
408 || sk_SRP_gN_insert(SRP_gN_tab,gN,0) == 0) 409 || sk_SRP_gN_insert(SRP_gN_tab,gN,0) == 0)
diff --git a/src/lib/libssl/src/crypto/store/str_meth.c b/src/lib/libssl/src/crypto/store/str_meth.c
index b3d4f9cc37..9d7c5ed98d 100644
--- a/src/lib/libssl/src/crypto/store/str_meth.c
+++ b/src/lib/libssl/src/crypto/store/str_meth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: str_meth.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: str_meth.c,v 1.7 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003. 3 * project 2003.
4 */ 4 */
@@ -65,8 +65,8 @@ STORE_create_method(char *name)
65{ 65{
66 STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); 66 STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD));
67 67
68 if (store_method) 68 if (store_method && name)
69 store_method->name = BUF_strdup(name); 69 store_method->name = strdup(name);
70 70
71 return store_method; 71 return store_method;
72} 72}
diff --git a/src/lib/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
index 4fabcd9909..baf86d7635 100644
--- a/src/lib/libssl/src/crypto/ui/ui_lib.c
+++ b/src/lib/libssl/src/crypto/ui/ui_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ui_lib.c,v 1.27 2014/07/13 16:03:10 beck Exp $ */ 1/* $OpenBSD: ui_lib.c,v 1.28 2014/07/22 02:21:20 beck Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -585,8 +585,8 @@ UI_create_method(char *name)
585{ 585{
586 UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); 586 UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD));
587 587
588 if (ui_method) 588 if (ui_method && name)
589 ui_method->name = BUF_strdup(name); 589 ui_method->name = strdup(name);
590 590
591 return ui_method; 591 return ui_method;
592} 592}
diff --git a/src/lib/libssl/src/crypto/x509/x509_vpm.c b/src/lib/libssl/src/crypto/x509/x509_vpm.c
index ec35267298..4ad2350222 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vpm.c
+++ b/src/lib/libssl/src/crypto/x509/x509_vpm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vpm.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: x509_vpm.c,v 1.10 2014/07/22 02:21:20 beck 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 2004. 3 * project 2004.
4 */ 4 */
@@ -213,7 +213,9 @@ int
213X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) 213X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
214{ 214{
215 free(param->name); 215 free(param->name);
216 param->name = BUF_strdup(name); 216 if (name == NULL)
217 return 1;
218 param->name = strdup(name);
217 if (param->name) 219 if (param->name)
218 return 1; 220 return 1;
219 return 0; 221 return 0;