summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeck <>2014-07-13 16:03:10 +0000
committerbeck <>2014-07-13 16:03:10 +0000
commit6e4dfa23733fddf37830d1039cf31a2ffb86bdaf (patch)
treec2bbb8405534dcf838bc686b6748045284f3966b /src
parent143b41eb184dd7da7b6f74162483016fbb5faab0 (diff)
downloadopenbsd-6e4dfa23733fddf37830d1039cf31a2ffb86bdaf.tar.gz
openbsd-6e4dfa23733fddf37830d1039cf31a2ffb86bdaf.tar.bz2
openbsd-6e4dfa23733fddf37830d1039cf31a2ffb86bdaf.zip
The bell tolls for BUF_strdup - Start the migration to using
intrinsics. This is the easy ones, a few left to check one at a time. ok miod@ deraadt@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/ameth_lib.c6
-rw-r--r--src/lib/libcrypto/asn1/asn_mime.c10
-rw-r--r--src/lib/libcrypto/bio/b_sock.c4
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c4
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c8
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c8
-rw-r--r--src/lib/libcrypto/engine/eng_dyn.c8
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_lib.c12
-rw-r--r--src/lib/libcrypto/srp/srp_vfy.c8
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c18
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_asid.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_enum.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c15
-rw-r--r--src/lib/libssl/s3_lib.c4
-rw-r--r--src/lib/libssl/src/apps/apps.c8
-rw-r--r--src/lib/libssl/src/apps/ca.c11
-rw-r--r--src/lib/libssl/src/apps/cms.c5
-rw-r--r--src/lib/libssl/src/apps/ocsp.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/ameth_lib.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn_mime.c10
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c4
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_acpt.c4
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_conn.c8
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_mod.c8
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_dyn.c8
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_lib.c12
-rw-r--r--src/lib/libssl/src/crypto/srp/srp_vfy.c8
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c18
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_addr.c6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_asid.c4
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_enum.c6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_purp.c6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_utl.c15
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c4
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c4
-rw-r--r--src/lib/libssl/src/ssl/t1_lib.c5
-rw-r--r--src/lib/libssl/ssl_sess.c4
-rw-r--r--src/lib/libssl/t1_lib.c5
40 files changed, 155 insertions, 145 deletions
diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c
index e9f73cb3a6..e88496cc9d 100644
--- a/src/lib/libcrypto/asn1/ameth_lib.c
+++ b/src/lib/libcrypto/asn1/ameth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ameth_lib.c,v 1.13 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: ameth_lib.c,v 1.14 2014/07/13 16:03:09 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 2006. 3 * project 2006.
4 */ 4 */
@@ -294,14 +294,14 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info)
294 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; 294 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
295 295
296 if (info) { 296 if (info) {
297 ameth->info = BUF_strdup(info); 297 ameth->info = strdup(info);
298 if (!ameth->info) 298 if (!ameth->info)
299 goto err; 299 goto err;
300 } else 300 } else
301 ameth->info = NULL; 301 ameth->info = NULL;
302 302
303 if (pem_str) { 303 if (pem_str) {
304 ameth->pem_str = BUF_strdup(pem_str); 304 ameth->pem_str = strdup(pem_str);
305 if (!ameth->pem_str) 305 if (!ameth->pem_str)
306 goto err; 306 goto err;
307 } else 307 } else
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c
index 994531837f..c153deca1e 100644
--- a/src/lib/libcrypto/asn1/asn_mime.c
+++ b/src/lib/libcrypto/asn1/asn_mime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_mime.c,v 1.21 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: asn_mime.c,v 1.22 2014/07/13 16:03:09 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. 3 * project.
4 */ 4 */
@@ -833,13 +833,13 @@ mime_hdr_new(char *name, char *value)
833 char *tmpname = NULL, *tmpval = NULL, *p; 833 char *tmpname = NULL, *tmpval = NULL, *p;
834 834
835 if (name) { 835 if (name) {
836 if (!(tmpname = BUF_strdup(name))) 836 if (!(tmpname = strdup(name)))
837 goto err; 837 goto err;
838 for (p = tmpname; *p; p++) 838 for (p = tmpname; *p; p++)
839 *p = tolower((unsigned char)*p); 839 *p = tolower((unsigned char)*p);
840 } 840 }
841 if (value) { 841 if (value) {
842 if (!(tmpval = BUF_strdup(value))) 842 if (!(tmpval = strdup(value)))
843 goto err; 843 goto err;
844 for (p = tmpval; *p; p++) 844 for (p = tmpval; *p; p++)
845 *p = tolower((unsigned char)*p); 845 *p = tolower((unsigned char)*p);
@@ -867,14 +867,14 @@ mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
867 MIME_PARAM *mparam; 867 MIME_PARAM *mparam;
868 868
869 if (name) { 869 if (name) {
870 tmpname = BUF_strdup(name); 870 tmpname = strdup(name);
871 if (!tmpname) 871 if (!tmpname)
872 goto err; 872 goto err;
873 for (p = tmpname; *p; p++) 873 for (p = tmpname; *p; p++)
874 *p = tolower((unsigned char)*p); 874 *p = tolower((unsigned char)*p);
875 } 875 }
876 if (value) { 876 if (value) {
877 tmpval = BUF_strdup(value); 877 tmpval = strdup(value);
878 if (!tmpval) 878 if (!tmpval)
879 goto err; 879 goto err;
880 } 880 }
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 8c37a3e175..ced0406bc1 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.54 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.55 2014/07/13 16:03:09 beck 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 *
@@ -235,7 +235,7 @@ BIO_get_accept_socket(char *host, int bind_mode)
235 unsigned long l; 235 unsigned long l;
236 int err_num; 236 int err_num;
237 237
238 if ((str = BUF_strdup(host)) == NULL) 238 if (host == NULL || (str = strdup(host)) == NULL)
239 return (-1); 239 return (-1);
240 240
241 h = p = NULL; 241 h = p = NULL;
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index c0316a2999..65d4bb2547 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_acpt.c,v 1.23 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: bss_acpt.c,v 1.24 2014/07/13 16:03:09 beck 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 *
@@ -354,7 +354,7 @@ acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
354 if (num == 0) { 354 if (num == 0) {
355 b->init = 1; 355 b->init = 1;
356 free(data->param_addr); 356 free(data->param_addr);
357 data->param_addr = BUF_strdup(ptr); 357 data->param_addr = strdup(ptr);
358 } else if (num == 1) { 358 } else if (num == 1) {
359 data->accept_nbio = (ptr != NULL); 359 data->accept_nbio = (ptr != NULL);
360 } else if (num == 2) { 360 } else if (num == 2) {
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index 8049f5c3f0..5120dabcb5 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_conn.c,v 1.29 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: bss_conn.c,v 1.30 2014/07/13 16:03:09 beck 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 *
@@ -152,7 +152,7 @@ conn_state(BIO *b, BIO_CONNECT *c)
152 break; 152 break;
153 } 153 }
154 free(c->param_port); 154 free(c->param_port);
155 c->param_port = BUF_strdup(p); 155 c->param_port = strdup(p);
156 } 156 }
157 } 157 }
158 158
@@ -471,10 +471,10 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr)
471 b->init = 1; 471 b->init = 1;
472 if (num == 0) { 472 if (num == 0) {
473 free(data->param_hostname); 473 free(data->param_hostname);
474 data->param_hostname = BUF_strdup(ptr); 474 data->param_hostname = strdup(ptr);
475 } else if (num == 1) { 475 } else if (num == 1) {
476 free(data->param_port); 476 free(data->param_port);
477 data->param_port = BUF_strdup(ptr); 477 data->param_port = strdup(ptr);
478 } else if (num == 2) { 478 } else if (num == 2) {
479 unsigned char *p = ptr; 479 unsigned char *p = ptr;
480 free(data->param_hostname); 480 free(data->param_hostname);
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index 36ffeb9f95..c4c429497c 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.23 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: conf_mod.c,v 1.24 2014/07/13 16:03:09 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 */
@@ -347,8 +347,8 @@ module_init(CONF_MODULE *pmod, char *name, char *value, const CONF *cnf)
347 goto err; 347 goto err;
348 348
349 imod->pmod = pmod; 349 imod->pmod = pmod;
350 imod->name = BUF_strdup(name); 350 imod->name = name ? strdup(name) : NULL;
351 imod->value = BUF_strdup(value); 351 imod->value = value ? strdup(value) : NULL;
352 imod->usr_data = NULL; 352 imod->usr_data = NULL;
353 353
354 if (!imod->name || !imod->value) 354 if (!imod->name || !imod->value)
@@ -547,7 +547,7 @@ CONF_get1_default_config_file(void)
547 if (issetugid() == 0) 547 if (issetugid() == 0)
548 file = getenv("OPENSSL_CONF"); 548 file = getenv("OPENSSL_CONF");
549 if (file) 549 if (file)
550 return BUF_strdup(file); 550 return strdup(file);
551 if (asprintf(&file, "%s/openssl.cnf", 551 if (asprintf(&file, "%s/openssl.cnf",
552 X509_get_default_cert_area()) == -1) 552 X509_get_default_cert_area()) == -1)
553 return (NULL); 553 return (NULL);
diff --git a/src/lib/libcrypto/engine/eng_dyn.c b/src/lib/libcrypto/engine/eng_dyn.c
index ec2ad7a8e7..dfb35a8403 100644
--- a/src/lib/libcrypto/engine/eng_dyn.c
+++ b/src/lib/libcrypto/engine/eng_dyn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_dyn.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ 1/* $OpenBSD: eng_dyn.c,v 1.12 2014/07/13 16:03:09 beck Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -348,7 +348,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
348 p = NULL; 348 p = NULL;
349 free((void *)ctx->DYNAMIC_LIBNAME); 349 free((void *)ctx->DYNAMIC_LIBNAME);
350 if (p) 350 if (p)
351 ctx->DYNAMIC_LIBNAME = BUF_strdup(p); 351 ctx->DYNAMIC_LIBNAME = strdup(p);
352 else 352 else
353 ctx->DYNAMIC_LIBNAME = NULL; 353 ctx->DYNAMIC_LIBNAME = NULL;
354 return (ctx->DYNAMIC_LIBNAME ? 1 : 0); 354 return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
@@ -361,7 +361,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
361 p = NULL; 361 p = NULL;
362 free((void *)ctx->engine_id); 362 free((void *)ctx->engine_id);
363 if (p) 363 if (p)
364 ctx->engine_id = BUF_strdup(p); 364 ctx->engine_id = strdup(p);
365 else 365 else
366 ctx->engine_id = NULL; 366 ctx->engine_id = NULL;
367 return (ctx->engine_id ? 1 : 0); 367 return (ctx->engine_id ? 1 : 0);
@@ -391,7 +391,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
391 return 0; 391 return 0;
392 } 392 }
393 { 393 {
394 char *tmp_str = BUF_strdup(p); 394 char *tmp_str = strdup(p);
395 if (!tmp_str) { 395 if (!tmp_str) {
396 ENGINEerr(ENGINE_F_DYNAMIC_CTRL, 396 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,
397 ERR_R_MALLOC_FAILURE); 397 ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/ocsp/ocsp_lib.c b/src/lib/libcrypto/ocsp/ocsp_lib.c
index 8599e48bff..51d2c719f2 100644
--- a/src/lib/libcrypto/ocsp/ocsp_lib.c
+++ b/src/lib/libcrypto/ocsp/ocsp_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_lib.c,v 1.14 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: ocsp_lib.c,v 1.15 2014/07/13 16:03:09 beck Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -191,7 +191,7 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
191 *ppath = NULL; 191 *ppath = NULL;
192 192
193 /* dup the buffer since we are going to mess with it */ 193 /* dup the buffer since we are going to mess with it */
194 buf = BUF_strdup(url); 194 buf = url ? strdup(url) : NULL;
195 if (!buf) 195 if (!buf)
196 goto mem_err; 196 goto mem_err;
197 197
@@ -222,9 +222,9 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
222 /* Check for trailing part of path */ 222 /* Check for trailing part of path */
223 p = strchr(p, '/'); 223 p = strchr(p, '/');
224 if (!p) 224 if (!p)
225 *ppath = BUF_strdup("/"); 225 *ppath = strdup("/");
226 else { 226 else {
227 *ppath = BUF_strdup(p); 227 *ppath = strdup(p);
228 /* Set start of path to 0 so hostname is valid */ 228 /* Set start of path to 0 so hostname is valid */
229 *p = '\0'; 229 *p = '\0';
230 } 230 }
@@ -244,11 +244,11 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
244 port = "80"; 244 port = "80";
245 } 245 }
246 246
247 *pport = BUF_strdup(port); 247 *pport = strdup(port);
248 if (!*pport) 248 if (!*pport)
249 goto mem_err; 249 goto mem_err;
250 250
251 *phost = BUF_strdup(host); 251 *phost = strdup(host);
252 252
253 if (!*phost) 253 if (!*phost)
254 goto mem_err; 254 goto mem_err;
diff --git a/src/lib/libcrypto/srp/srp_vfy.c b/src/lib/libcrypto/srp/srp_vfy.c
index 0981890086..6de843527d 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.7 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: srp_vfy.c,v 1.8 2014/07/13 16:03:10 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.
@@ -218,9 +218,9 @@ static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,
218static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id, 218static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
219 const char *info) 219 const char *info)
220 { 220 {
221 if (id != NULL && NULL == (vinfo->id = BUF_strdup(id))) 221 if (id != NULL && NULL == (vinfo->id = strdup(id)))
222 return 0; 222 return 0;
223 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info))) ; 223 return (info == NULL || NULL != (vinfo->info = strdup(info))) ;
224 } 224 }
225 225
226static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s, 226static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
@@ -261,7 +261,7 @@ SRP_VBASE *SRP_VBASE_new(char *seed_key)
261 vb->default_N = NULL; 261 vb->default_N = NULL;
262 vb->seed_key = NULL; 262 vb->seed_key = NULL;
263 if ((seed_key != NULL) && 263 if ((seed_key != NULL) &&
264 (vb->seed_key = BUF_strdup(seed_key)) == NULL) 264 (vb->seed_key = strdup(seed_key)) == NULL)
265 { 265 {
266 sk_SRP_user_pwd_free(vb->users_pwd); 266 sk_SRP_user_pwd_free(vb->users_pwd);
267 sk_SRP_gN_cache_free(vb->gN_cache); 267 sk_SRP_gN_cache_free(vb->gN_cache);
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index a33484c72b..4fabcd9909 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.26 2014/07/11 16:22:29 deraadt Exp $ */ 1/* $OpenBSD: ui_lib.c,v 1.27 2014/07/13 16:03:10 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 */
@@ -245,7 +245,7 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
245 char *prompt_copy = NULL; 245 char *prompt_copy = NULL;
246 246
247 if (prompt) { 247 if (prompt) {
248 prompt_copy = BUF_strdup(prompt); 248 prompt_copy = strdup(prompt);
249 if (prompt_copy == NULL) { 249 if (prompt_copy == NULL) {
250 UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE); 250 UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
251 return 0; 251 return 0;
@@ -270,7 +270,7 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags,
270 char *prompt_copy = NULL; 270 char *prompt_copy = NULL;
271 271
272 if (prompt) { 272 if (prompt) {
273 prompt_copy = BUF_strdup(prompt); 273 prompt_copy = strdup(prompt);
274 if (prompt_copy == NULL) { 274 if (prompt_copy == NULL) {
275 UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE); 275 UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE);
276 return -1; 276 return -1;
@@ -298,28 +298,28 @@ UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
298 char *cancel_chars_copy = NULL; 298 char *cancel_chars_copy = NULL;
299 299
300 if (prompt) { 300 if (prompt) {
301 prompt_copy = BUF_strdup(prompt); 301 prompt_copy = strdup(prompt);
302 if (prompt_copy == NULL) { 302 if (prompt_copy == NULL) {
303 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 303 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
304 goto err; 304 goto err;
305 } 305 }
306 } 306 }
307 if (action_desc) { 307 if (action_desc) {
308 action_desc_copy = BUF_strdup(action_desc); 308 action_desc_copy = strdup(action_desc);
309 if (action_desc_copy == NULL) { 309 if (action_desc_copy == NULL) {
310 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 310 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
311 goto err; 311 goto err;
312 } 312 }
313 } 313 }
314 if (ok_chars) { 314 if (ok_chars) {
315 ok_chars_copy = BUF_strdup(ok_chars); 315 ok_chars_copy = strdup(ok_chars);
316 if (ok_chars_copy == NULL) { 316 if (ok_chars_copy == NULL) {
317 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 317 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
318 goto err; 318 goto err;
319 } 319 }
320 } 320 }
321 if (cancel_chars) { 321 if (cancel_chars) {
322 cancel_chars_copy = BUF_strdup(cancel_chars); 322 cancel_chars_copy = strdup(cancel_chars);
323 if (cancel_chars_copy == NULL) { 323 if (cancel_chars_copy == NULL) {
324 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 324 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
325 goto err; 325 goto err;
@@ -350,7 +350,7 @@ UI_dup_info_string(UI *ui, const char *text)
350 char *text_copy = NULL; 350 char *text_copy = NULL;
351 351
352 if (text) { 352 if (text) {
353 text_copy = BUF_strdup(text); 353 text_copy = strdup(text);
354 if (text_copy == NULL) { 354 if (text_copy == NULL) {
355 UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE); 355 UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE);
356 return -1; 356 return -1;
@@ -373,7 +373,7 @@ UI_dup_error_string(UI *ui, const char *text)
373 char *text_copy = NULL; 373 char *text_copy = NULL;
374 374
375 if (text) { 375 if (text) {
376 text_copy = BUF_strdup(text); 376 text_copy = strdup(text);
377 if (text_copy == NULL) { 377 if (text_copy == NULL) {
378 UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE); 378 UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE);
379 return -1; 379 return -1;
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
index 28031a0754..1e016586c7 100644
--- a/src/lib/libcrypto/x509v3/v3_addr.c
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_addr.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_addr.c,v 1.13 2014/07/13 16:03:10 beck Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -1032,9 +1032,9 @@ v2i_IPAddrBlocks(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
1032 goto err; 1032 goto err;
1033 } 1033 }
1034 t += strspn(t, " \t"); 1034 t += strspn(t, " \t");
1035 s = BUF_strdup(t); 1035 s = strdup(t);
1036 } else { 1036 } else {
1037 s = BUF_strdup(val->value); 1037 s = strdup(val->value);
1038 } 1038 }
1039 if (s == NULL) { 1039 if (s == NULL) {
1040 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, 1040 X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c
index 4ff8f0da37..680eed31ec 100644
--- a/src/lib/libcrypto/x509v3/v3_asid.c
+++ b/src/lib/libcrypto/x509v3/v3_asid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_asid.c,v 1.10 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_asid.c,v 1.11 2014/07/13 16:03:10 beck Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -643,7 +643,7 @@ v2i_ASIdentifiers(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
643 goto err; 643 goto err;
644 } 644 }
645 } else { 645 } else {
646 char *s = BUF_strdup(val->value); 646 char *s = strdup(val->value);
647 if (s == NULL) { 647 if (s == NULL) {
648 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, 648 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
649 ERR_R_MALLOC_FAILURE); 649 ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c
index 8900d7e01b..c09601edad 100644
--- a/src/lib/libcrypto/x509v3/v3_enum.c
+++ b/src/lib/libcrypto/x509v3/v3_enum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_enum.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_enum.c,v 1.10 2014/07/13 16:03:10 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 1999. 3 * project 1999.
4 */ 4 */
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60#include <string.h>
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ENUMERATED_NAMES crl_reasons[] = { 63static ENUMERATED_NAMES crl_reasons[] = {
@@ -93,7 +93,7 @@ i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e)
93 strval = ASN1_ENUMERATED_get(e); 93 strval = ASN1_ENUMERATED_get(e);
94 for (enam = method->usr_data; enam->lname; enam++) { 94 for (enam = method->usr_data; enam->lname; enam++) {
95 if (strval == enam->bitnum) 95 if (strval == enam->bitnum)
96 return BUF_strdup(enam->lname); 96 return strdup(enam->lname);
97 } 97 }
98 return i2s_ASN1_ENUMERATED(method, e); 98 return i2s_ASN1_ENUMERATED(method, e);
99} 99}
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index 03fb427277..b8db8d69a2 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_purp.c,v 1.21 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_purp.c,v 1.22 2014/07/13 16:03:10 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 2001. 3 * project 2001.
4 */ 4 */
@@ -227,8 +227,8 @@ X509_PURPOSE_add(int id, int trust, int flags,
227 free(ptmp->sname); 227 free(ptmp->sname);
228 } 228 }
229 /* dup supplied name */ 229 /* dup supplied name */
230 ptmp->name = BUF_strdup(name); 230 ptmp->name = name ? strdup(name) : NULL;
231 ptmp->sname = BUF_strdup(sname); 231 ptmp->sname = sname ? strdup(sname) : NULL;
232 if (!ptmp->name || !ptmp->sname) { 232 if (!ptmp->name || !ptmp->sname) {
233 free(ptmp->name); 233 free(ptmp->name);
234 free(ptmp->sname); 234 free(ptmp->sname);
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index d9987e32a5..99090f3cd2 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_utl.c,v 1.22 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_utl.c,v 1.23 2014/07/13 16:03:10 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. 3 * project.
4 */ 4 */
@@ -87,9 +87,9 @@ X509V3_add_value(const char *name, const char *value,
87 CONF_VALUE *vtmp = NULL; 87 CONF_VALUE *vtmp = NULL;
88 char *tname = NULL, *tvalue = NULL; 88 char *tname = NULL, *tvalue = NULL;
89 89
90 if (name && !(tname = BUF_strdup(name))) 90 if (name && !(tname = strdup(name)))
91 goto err; 91 goto err;
92 if (value && !(tvalue = BUF_strdup(value))) 92 if (value && !(tvalue = strdup(value)))
93 goto err; 93 goto err;
94 if (!(vtmp = malloc(sizeof(CONF_VALUE)))) 94 if (!(vtmp = malloc(sizeof(CONF_VALUE))))
95 goto err; 95 goto err;
@@ -301,7 +301,10 @@ X509V3_parse_list(const char *line)
301 int state; 301 int state;
302 302
303 /* We are going to modify the line so copy it first */ 303 /* We are going to modify the line so copy it first */
304 linebuf = BUF_strdup(line); 304 if ((linebuf = strdup(line)) == NULL) {
305 X509V3err(X509V3_F_X509V3_PARSE_LIST, ERR_R_MALLOC_FAILURE);
306 goto err;
307 }
305 state = HDR_NAME; 308 state = HDR_NAME;
306 ntmp = NULL; 309 ntmp = NULL;
307 310
@@ -632,7 +635,7 @@ append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
632 /* Don't add duplicates */ 635 /* Don't add duplicates */
633 if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) 636 if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
634 return 1; 637 return 1;
635 emtmp = BUF_strdup((char *)email->data); 638 emtmp = strdup((char *)email->data);
636 if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) { 639 if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
637 X509_email_free(*sk); 640 X509_email_free(*sk);
638 *sk = NULL; 641 *sk = NULL;
@@ -686,7 +689,7 @@ a2i_IPADDRESS_NC(const char *ipasc)
686 p = strchr(ipasc, '/'); 689 p = strchr(ipasc, '/');
687 if (!p) 690 if (!p)
688 return NULL; 691 return NULL;
689 iptmp = BUF_strdup(ipasc); 692 iptmp = strdup(ipasc);
690 if (!iptmp) 693 if (!iptmp)
691 return NULL; 694 return NULL;
692 p = iptmp + (p - ipasc); 695 p = iptmp + (p - ipasc);
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index decdda90a3..8a40b758a9 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.70 2014/07/12 22:33:39 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.71 2014/07/13 16:03:10 beck 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 *
@@ -2566,7 +2566,7 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
2566 SSL_R_SSL3_EXT_INVALID_SERVERNAME); 2566 SSL_R_SSL3_EXT_INVALID_SERVERNAME);
2567 return 0; 2567 return 0;
2568 } 2568 }
2569 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) 2569 if ((s->tlsext_hostname = strdup((char *)parg))
2570 == NULL) { 2570 == NULL) {
2571 SSLerr(SSL_F_SSL3_CTRL, 2571 SSLerr(SSL_F_SSL3_CTRL,
2572 ERR_R_INTERNAL_ERROR); 2572 ERR_R_INTERNAL_ERROR);
diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c
index 84dd13339d..fdbd436acc 100644
--- a/src/lib/libssl/src/apps/apps.c
+++ b/src/lib/libssl/src/apps/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.65 2014/07/12 17:54:31 jsing Exp $ */ 1/* $OpenBSD: apps.c,v 1.66 2014/07/13 16:03:09 beck 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 *
@@ -473,7 +473,7 @@ app_get_pass(BIO *err, char *arg, int keepbio)
473 int i; 473 int i;
474 474
475 if (!strncmp(arg, "pass:", 5)) 475 if (!strncmp(arg, "pass:", 5))
476 return BUF_strdup(arg + 5); 476 return strdup(arg + 5);
477 if (!strncmp(arg, "env:", 4)) { 477 if (!strncmp(arg, "env:", 4)) {
478 tmp = getenv(arg + 4); 478 tmp = getenv(arg + 4);
479 if (!tmp) { 479 if (!tmp) {
@@ -481,7 +481,7 @@ app_get_pass(BIO *err, char *arg, int keepbio)
481 arg + 4); 481 arg + 4);
482 return NULL; 482 return NULL;
483 } 483 }
484 return BUF_strdup(tmp); 484 return strdup(tmp);
485 } 485 }
486 if (!keepbio || !pwdbio) { 486 if (!keepbio || !pwdbio) {
487 if (!strncmp(arg, "file:", 5)) { 487 if (!strncmp(arg, "file:", 5)) {
@@ -537,7 +537,7 @@ app_get_pass(BIO *err, char *arg, int keepbio)
537 tmp = strchr(tpass, '\n'); 537 tmp = strchr(tpass, '\n');
538 if (tmp) 538 if (tmp)
539 *tmp = 0; 539 *tmp = 0;
540 return BUF_strdup(tpass); 540 return strdup(tpass);
541} 541}
542 542
543int 543int
diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c
index 8ebfd77f0a..ae711a2e07 100644
--- a/src/lib/libssl/src/apps/ca.c
+++ b/src/lib/libssl/src/apps/ca.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ca.c,v 1.62 2014/07/12 17:54:31 jsing Exp $ */ 1/* $OpenBSD: ca.c,v 1.63 2014/07/13 16:03:09 beck 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 *
@@ -1729,7 +1729,7 @@ again2:
1729 } 1729 }
1730 1730
1731 if (BN_is_zero(serial)) 1731 if (BN_is_zero(serial))
1732 row[DB_serial] = BUF_strdup("00"); 1732 row[DB_serial] = strdup("00");
1733 else 1733 else
1734 row[DB_serial] = BN_bn2hex(serial); 1734 row[DB_serial] = BN_bn2hex(serial);
1735 if (row[DB_serial] == NULL) { 1735 if (row[DB_serial] == NULL) {
@@ -2195,7 +2195,7 @@ do_revoke(X509 * x509, CA_DB * db, int type, char *value)
2195 if (!bn) 2195 if (!bn)
2196 goto err; 2196 goto err;
2197 if (BN_is_zero(bn)) 2197 if (BN_is_zero(bn))
2198 row[DB_serial] = BUF_strdup("00"); 2198 row[DB_serial] = strdup("00");
2199 else 2199 else
2200 row[DB_serial] = BN_bn2hex(bn); 2200 row[DB_serial] = BN_bn2hex(bn);
2201 BN_free(bn); 2201 BN_free(bn);
@@ -2631,7 +2631,10 @@ unpack_revinfo(ASN1_TIME ** prevtm, int *preason, ASN1_OBJECT ** phold,
2631 ASN1_OBJECT *hold = NULL; 2631 ASN1_OBJECT *hold = NULL;
2632 ASN1_GENERALIZEDTIME *comp_time = NULL; 2632 ASN1_GENERALIZEDTIME *comp_time = NULL;
2633 2633
2634 tmp = BUF_strdup(str); 2634 if ((tmp = strdup(str)) == NULL) {
2635 BIO_printf(bio_err, "malloc failed\n");
2636 goto err;
2637 }
2635 p = strchr(tmp, ','); 2638 p = strchr(tmp, ',');
2636 rtime_str = tmp; 2639 rtime_str = tmp;
2637 2640
diff --git a/src/lib/libssl/src/apps/cms.c b/src/lib/libssl/src/apps/cms.c
index bafbce1f5c..91203bc719 100644
--- a/src/lib/libssl/src/apps/cms.c
+++ b/src/lib/libssl/src/apps/cms.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms.c,v 1.19 2014/07/12 17:54:31 jsing Exp $ */ 1/* $OpenBSD: cms.c,v 1.20 2014/07/13 16:03:09 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. 3 * project.
4 */ 4 */
@@ -747,8 +747,7 @@ argerr:
747 secret_keyid = NULL; 747 secret_keyid = NULL;
748 } 748 }
749 if (pwri_pass) { 749 if (pwri_pass) {
750 pwri_tmp = 750 pwri_tmp = strdup(pwri_pass);
751 (unsigned char *)BUF_strdup((char *)pwri_pass);
752 if (!pwri_tmp) 751 if (!pwri_tmp)
753 goto end; 752 goto end;
754 if (!CMS_add0_recipient_password(cms, -1, NID_undef, 753 if (!CMS_add0_recipient_password(cms, -1, NID_undef,
diff --git a/src/lib/libssl/src/apps/ocsp.c b/src/lib/libssl/src/apps/ocsp.c
index b431a3c9fd..9bb7da0d88 100644
--- a/src/lib/libssl/src/apps/ocsp.c
+++ b/src/lib/libssl/src/apps/ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp.c,v 1.29 2014/07/12 19:31:21 jsing Exp $ */ 1/* $OpenBSD: ocsp.c,v 1.30 2014/07/13 16:03:09 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 2000. 3 * project 2000.
4 */ 4 */
@@ -991,7 +991,7 @@ lookup_serial(CA_DB * db, ASN1_INTEGER * ser)
991 OPENSSL_assert(bn); /* FIXME: should report an error at this 991 OPENSSL_assert(bn); /* FIXME: should report an error at this
992 * point and abort */ 992 * point and abort */
993 if (BN_is_zero(bn)) 993 if (BN_is_zero(bn))
994 itmp = BUF_strdup("00"); 994 itmp = strdup("00");
995 else 995 else
996 itmp = BN_bn2hex(bn); 996 itmp = BN_bn2hex(bn);
997 row[DB_serial] = itmp; 997 row[DB_serial] = itmp;
diff --git a/src/lib/libssl/src/crypto/asn1/ameth_lib.c b/src/lib/libssl/src/crypto/asn1/ameth_lib.c
index e9f73cb3a6..e88496cc9d 100644
--- a/src/lib/libssl/src/crypto/asn1/ameth_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/ameth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ameth_lib.c,v 1.13 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: ameth_lib.c,v 1.14 2014/07/13 16:03:09 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 2006. 3 * project 2006.
4 */ 4 */
@@ -294,14 +294,14 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info)
294 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; 294 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
295 295
296 if (info) { 296 if (info) {
297 ameth->info = BUF_strdup(info); 297 ameth->info = strdup(info);
298 if (!ameth->info) 298 if (!ameth->info)
299 goto err; 299 goto err;
300 } else 300 } else
301 ameth->info = NULL; 301 ameth->info = NULL;
302 302
303 if (pem_str) { 303 if (pem_str) {
304 ameth->pem_str = BUF_strdup(pem_str); 304 ameth->pem_str = strdup(pem_str);
305 if (!ameth->pem_str) 305 if (!ameth->pem_str)
306 goto err; 306 goto err;
307 } else 307 } else
diff --git a/src/lib/libssl/src/crypto/asn1/asn_mime.c b/src/lib/libssl/src/crypto/asn1/asn_mime.c
index 994531837f..c153deca1e 100644
--- a/src/lib/libssl/src/crypto/asn1/asn_mime.c
+++ b/src/lib/libssl/src/crypto/asn1/asn_mime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_mime.c,v 1.21 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: asn_mime.c,v 1.22 2014/07/13 16:03:09 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. 3 * project.
4 */ 4 */
@@ -833,13 +833,13 @@ mime_hdr_new(char *name, char *value)
833 char *tmpname = NULL, *tmpval = NULL, *p; 833 char *tmpname = NULL, *tmpval = NULL, *p;
834 834
835 if (name) { 835 if (name) {
836 if (!(tmpname = BUF_strdup(name))) 836 if (!(tmpname = strdup(name)))
837 goto err; 837 goto err;
838 for (p = tmpname; *p; p++) 838 for (p = tmpname; *p; p++)
839 *p = tolower((unsigned char)*p); 839 *p = tolower((unsigned char)*p);
840 } 840 }
841 if (value) { 841 if (value) {
842 if (!(tmpval = BUF_strdup(value))) 842 if (!(tmpval = strdup(value)))
843 goto err; 843 goto err;
844 for (p = tmpval; *p; p++) 844 for (p = tmpval; *p; p++)
845 *p = tolower((unsigned char)*p); 845 *p = tolower((unsigned char)*p);
@@ -867,14 +867,14 @@ mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
867 MIME_PARAM *mparam; 867 MIME_PARAM *mparam;
868 868
869 if (name) { 869 if (name) {
870 tmpname = BUF_strdup(name); 870 tmpname = strdup(name);
871 if (!tmpname) 871 if (!tmpname)
872 goto err; 872 goto err;
873 for (p = tmpname; *p; p++) 873 for (p = tmpname; *p; p++)
874 *p = tolower((unsigned char)*p); 874 *p = tolower((unsigned char)*p);
875 } 875 }
876 if (value) { 876 if (value) {
877 tmpval = BUF_strdup(value); 877 tmpval = strdup(value);
878 if (!tmpval) 878 if (!tmpval)
879 goto err; 879 goto err;
880 } 880 }
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index 8c37a3e175..ced0406bc1 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.54 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.55 2014/07/13 16:03:09 beck 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 *
@@ -235,7 +235,7 @@ BIO_get_accept_socket(char *host, int bind_mode)
235 unsigned long l; 235 unsigned long l;
236 int err_num; 236 int err_num;
237 237
238 if ((str = BUF_strdup(host)) == NULL) 238 if (host == NULL || (str = strdup(host)) == NULL)
239 return (-1); 239 return (-1);
240 240
241 h = p = NULL; 241 h = p = NULL;
diff --git a/src/lib/libssl/src/crypto/bio/bss_acpt.c b/src/lib/libssl/src/crypto/bio/bss_acpt.c
index c0316a2999..65d4bb2547 100644
--- a/src/lib/libssl/src/crypto/bio/bss_acpt.c
+++ b/src/lib/libssl/src/crypto/bio/bss_acpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_acpt.c,v 1.23 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: bss_acpt.c,v 1.24 2014/07/13 16:03:09 beck 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 *
@@ -354,7 +354,7 @@ acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
354 if (num == 0) { 354 if (num == 0) {
355 b->init = 1; 355 b->init = 1;
356 free(data->param_addr); 356 free(data->param_addr);
357 data->param_addr = BUF_strdup(ptr); 357 data->param_addr = strdup(ptr);
358 } else if (num == 1) { 358 } else if (num == 1) {
359 data->accept_nbio = (ptr != NULL); 359 data->accept_nbio = (ptr != NULL);
360 } else if (num == 2) { 360 } else if (num == 2) {
diff --git a/src/lib/libssl/src/crypto/bio/bss_conn.c b/src/lib/libssl/src/crypto/bio/bss_conn.c
index 8049f5c3f0..5120dabcb5 100644
--- a/src/lib/libssl/src/crypto/bio/bss_conn.c
+++ b/src/lib/libssl/src/crypto/bio/bss_conn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_conn.c,v 1.29 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: bss_conn.c,v 1.30 2014/07/13 16:03:09 beck 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 *
@@ -152,7 +152,7 @@ conn_state(BIO *b, BIO_CONNECT *c)
152 break; 152 break;
153 } 153 }
154 free(c->param_port); 154 free(c->param_port);
155 c->param_port = BUF_strdup(p); 155 c->param_port = strdup(p);
156 } 156 }
157 } 157 }
158 158
@@ -471,10 +471,10 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr)
471 b->init = 1; 471 b->init = 1;
472 if (num == 0) { 472 if (num == 0) {
473 free(data->param_hostname); 473 free(data->param_hostname);
474 data->param_hostname = BUF_strdup(ptr); 474 data->param_hostname = strdup(ptr);
475 } else if (num == 1) { 475 } else if (num == 1) {
476 free(data->param_port); 476 free(data->param_port);
477 data->param_port = BUF_strdup(ptr); 477 data->param_port = strdup(ptr);
478 } else if (num == 2) { 478 } else if (num == 2) {
479 unsigned char *p = ptr; 479 unsigned char *p = ptr;
480 free(data->param_hostname); 480 free(data->param_hostname);
diff --git a/src/lib/libssl/src/crypto/conf/conf_mod.c b/src/lib/libssl/src/crypto/conf/conf_mod.c
index 36ffeb9f95..c4c429497c 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.23 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: conf_mod.c,v 1.24 2014/07/13 16:03:09 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 */
@@ -347,8 +347,8 @@ module_init(CONF_MODULE *pmod, char *name, char *value, const CONF *cnf)
347 goto err; 347 goto err;
348 348
349 imod->pmod = pmod; 349 imod->pmod = pmod;
350 imod->name = BUF_strdup(name); 350 imod->name = name ? strdup(name) : NULL;
351 imod->value = BUF_strdup(value); 351 imod->value = value ? strdup(value) : NULL;
352 imod->usr_data = NULL; 352 imod->usr_data = NULL;
353 353
354 if (!imod->name || !imod->value) 354 if (!imod->name || !imod->value)
@@ -547,7 +547,7 @@ CONF_get1_default_config_file(void)
547 if (issetugid() == 0) 547 if (issetugid() == 0)
548 file = getenv("OPENSSL_CONF"); 548 file = getenv("OPENSSL_CONF");
549 if (file) 549 if (file)
550 return BUF_strdup(file); 550 return strdup(file);
551 if (asprintf(&file, "%s/openssl.cnf", 551 if (asprintf(&file, "%s/openssl.cnf",
552 X509_get_default_cert_area()) == -1) 552 X509_get_default_cert_area()) == -1)
553 return (NULL); 553 return (NULL);
diff --git a/src/lib/libssl/src/crypto/engine/eng_dyn.c b/src/lib/libssl/src/crypto/engine/eng_dyn.c
index ec2ad7a8e7..dfb35a8403 100644
--- a/src/lib/libssl/src/crypto/engine/eng_dyn.c
+++ b/src/lib/libssl/src/crypto/engine/eng_dyn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_dyn.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ 1/* $OpenBSD: eng_dyn.c,v 1.12 2014/07/13 16:03:09 beck Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -348,7 +348,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
348 p = NULL; 348 p = NULL;
349 free((void *)ctx->DYNAMIC_LIBNAME); 349 free((void *)ctx->DYNAMIC_LIBNAME);
350 if (p) 350 if (p)
351 ctx->DYNAMIC_LIBNAME = BUF_strdup(p); 351 ctx->DYNAMIC_LIBNAME = strdup(p);
352 else 352 else
353 ctx->DYNAMIC_LIBNAME = NULL; 353 ctx->DYNAMIC_LIBNAME = NULL;
354 return (ctx->DYNAMIC_LIBNAME ? 1 : 0); 354 return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
@@ -361,7 +361,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
361 p = NULL; 361 p = NULL;
362 free((void *)ctx->engine_id); 362 free((void *)ctx->engine_id);
363 if (p) 363 if (p)
364 ctx->engine_id = BUF_strdup(p); 364 ctx->engine_id = strdup(p);
365 else 365 else
366 ctx->engine_id = NULL; 366 ctx->engine_id = NULL;
367 return (ctx->engine_id ? 1 : 0); 367 return (ctx->engine_id ? 1 : 0);
@@ -391,7 +391,7 @@ dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
391 return 0; 391 return 0;
392 } 392 }
393 { 393 {
394 char *tmp_str = BUF_strdup(p); 394 char *tmp_str = strdup(p);
395 if (!tmp_str) { 395 if (!tmp_str) {
396 ENGINEerr(ENGINE_F_DYNAMIC_CTRL, 396 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,
397 ERR_R_MALLOC_FAILURE); 397 ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libssl/src/crypto/ocsp/ocsp_lib.c b/src/lib/libssl/src/crypto/ocsp/ocsp_lib.c
index 8599e48bff..51d2c719f2 100644
--- a/src/lib/libssl/src/crypto/ocsp/ocsp_lib.c
+++ b/src/lib/libssl/src/crypto/ocsp/ocsp_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_lib.c,v 1.14 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: ocsp_lib.c,v 1.15 2014/07/13 16:03:09 beck Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -191,7 +191,7 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
191 *ppath = NULL; 191 *ppath = NULL;
192 192
193 /* dup the buffer since we are going to mess with it */ 193 /* dup the buffer since we are going to mess with it */
194 buf = BUF_strdup(url); 194 buf = url ? strdup(url) : NULL;
195 if (!buf) 195 if (!buf)
196 goto mem_err; 196 goto mem_err;
197 197
@@ -222,9 +222,9 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
222 /* Check for trailing part of path */ 222 /* Check for trailing part of path */
223 p = strchr(p, '/'); 223 p = strchr(p, '/');
224 if (!p) 224 if (!p)
225 *ppath = BUF_strdup("/"); 225 *ppath = strdup("/");
226 else { 226 else {
227 *ppath = BUF_strdup(p); 227 *ppath = strdup(p);
228 /* Set start of path to 0 so hostname is valid */ 228 /* Set start of path to 0 so hostname is valid */
229 *p = '\0'; 229 *p = '\0';
230 } 230 }
@@ -244,11 +244,11 @@ OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
244 port = "80"; 244 port = "80";
245 } 245 }
246 246
247 *pport = BUF_strdup(port); 247 *pport = strdup(port);
248 if (!*pport) 248 if (!*pport)
249 goto mem_err; 249 goto mem_err;
250 250
251 *phost = BUF_strdup(host); 251 *phost = strdup(host);
252 252
253 if (!*phost) 253 if (!*phost)
254 goto mem_err; 254 goto mem_err;
diff --git a/src/lib/libssl/src/crypto/srp/srp_vfy.c b/src/lib/libssl/src/crypto/srp/srp_vfy.c
index 0981890086..6de843527d 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.7 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: srp_vfy.c,v 1.8 2014/07/13 16:03:10 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.
@@ -218,9 +218,9 @@ static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,
218static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id, 218static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
219 const char *info) 219 const char *info)
220 { 220 {
221 if (id != NULL && NULL == (vinfo->id = BUF_strdup(id))) 221 if (id != NULL && NULL == (vinfo->id = strdup(id)))
222 return 0; 222 return 0;
223 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info))) ; 223 return (info == NULL || NULL != (vinfo->info = strdup(info))) ;
224 } 224 }
225 225
226static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s, 226static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
@@ -261,7 +261,7 @@ SRP_VBASE *SRP_VBASE_new(char *seed_key)
261 vb->default_N = NULL; 261 vb->default_N = NULL;
262 vb->seed_key = NULL; 262 vb->seed_key = NULL;
263 if ((seed_key != NULL) && 263 if ((seed_key != NULL) &&
264 (vb->seed_key = BUF_strdup(seed_key)) == NULL) 264 (vb->seed_key = strdup(seed_key)) == NULL)
265 { 265 {
266 sk_SRP_user_pwd_free(vb->users_pwd); 266 sk_SRP_user_pwd_free(vb->users_pwd);
267 sk_SRP_gN_cache_free(vb->gN_cache); 267 sk_SRP_gN_cache_free(vb->gN_cache);
diff --git a/src/lib/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
index a33484c72b..4fabcd9909 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.26 2014/07/11 16:22:29 deraadt Exp $ */ 1/* $OpenBSD: ui_lib.c,v 1.27 2014/07/13 16:03:10 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 */
@@ -245,7 +245,7 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
245 char *prompt_copy = NULL; 245 char *prompt_copy = NULL;
246 246
247 if (prompt) { 247 if (prompt) {
248 prompt_copy = BUF_strdup(prompt); 248 prompt_copy = strdup(prompt);
249 if (prompt_copy == NULL) { 249 if (prompt_copy == NULL) {
250 UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE); 250 UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
251 return 0; 251 return 0;
@@ -270,7 +270,7 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags,
270 char *prompt_copy = NULL; 270 char *prompt_copy = NULL;
271 271
272 if (prompt) { 272 if (prompt) {
273 prompt_copy = BUF_strdup(prompt); 273 prompt_copy = strdup(prompt);
274 if (prompt_copy == NULL) { 274 if (prompt_copy == NULL) {
275 UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE); 275 UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE);
276 return -1; 276 return -1;
@@ -298,28 +298,28 @@ UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
298 char *cancel_chars_copy = NULL; 298 char *cancel_chars_copy = NULL;
299 299
300 if (prompt) { 300 if (prompt) {
301 prompt_copy = BUF_strdup(prompt); 301 prompt_copy = strdup(prompt);
302 if (prompt_copy == NULL) { 302 if (prompt_copy == NULL) {
303 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 303 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
304 goto err; 304 goto err;
305 } 305 }
306 } 306 }
307 if (action_desc) { 307 if (action_desc) {
308 action_desc_copy = BUF_strdup(action_desc); 308 action_desc_copy = strdup(action_desc);
309 if (action_desc_copy == NULL) { 309 if (action_desc_copy == NULL) {
310 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 310 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
311 goto err; 311 goto err;
312 } 312 }
313 } 313 }
314 if (ok_chars) { 314 if (ok_chars) {
315 ok_chars_copy = BUF_strdup(ok_chars); 315 ok_chars_copy = strdup(ok_chars);
316 if (ok_chars_copy == NULL) { 316 if (ok_chars_copy == NULL) {
317 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 317 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
318 goto err; 318 goto err;
319 } 319 }
320 } 320 }
321 if (cancel_chars) { 321 if (cancel_chars) {
322 cancel_chars_copy = BUF_strdup(cancel_chars); 322 cancel_chars_copy = strdup(cancel_chars);
323 if (cancel_chars_copy == NULL) { 323 if (cancel_chars_copy == NULL) {
324 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); 324 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
325 goto err; 325 goto err;
@@ -350,7 +350,7 @@ UI_dup_info_string(UI *ui, const char *text)
350 char *text_copy = NULL; 350 char *text_copy = NULL;
351 351
352 if (text) { 352 if (text) {
353 text_copy = BUF_strdup(text); 353 text_copy = strdup(text);
354 if (text_copy == NULL) { 354 if (text_copy == NULL) {
355 UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE); 355 UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE);
356 return -1; 356 return -1;
@@ -373,7 +373,7 @@ UI_dup_error_string(UI *ui, const char *text)
373 char *text_copy = NULL; 373 char *text_copy = NULL;
374 374
375 if (text) { 375 if (text) {
376 text_copy = BUF_strdup(text); 376 text_copy = strdup(text);
377 if (text_copy == NULL) { 377 if (text_copy == NULL) {
378 UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE); 378 UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE);
379 return -1; 379 return -1;
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_addr.c b/src/lib/libssl/src/crypto/x509v3/v3_addr.c
index 28031a0754..1e016586c7 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_addr.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_addr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_addr.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_addr.c,v 1.13 2014/07/13 16:03:10 beck Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -1032,9 +1032,9 @@ v2i_IPAddrBlocks(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
1032 goto err; 1032 goto err;
1033 } 1033 }
1034 t += strspn(t, " \t"); 1034 t += strspn(t, " \t");
1035 s = BUF_strdup(t); 1035 s = strdup(t);
1036 } else { 1036 } else {
1037 s = BUF_strdup(val->value); 1037 s = strdup(val->value);
1038 } 1038 }
1039 if (s == NULL) { 1039 if (s == NULL) {
1040 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, 1040 X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_asid.c b/src/lib/libssl/src/crypto/x509v3/v3_asid.c
index 4ff8f0da37..680eed31ec 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_asid.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_asid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_asid.c,v 1.10 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_asid.c,v 1.11 2014/07/13 16:03:10 beck Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -643,7 +643,7 @@ v2i_ASIdentifiers(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
643 goto err; 643 goto err;
644 } 644 }
645 } else { 645 } else {
646 char *s = BUF_strdup(val->value); 646 char *s = strdup(val->value);
647 if (s == NULL) { 647 if (s == NULL) {
648 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, 648 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
649 ERR_R_MALLOC_FAILURE); 649 ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_enum.c b/src/lib/libssl/src/crypto/x509v3/v3_enum.c
index 8900d7e01b..c09601edad 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_enum.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_enum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_enum.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_enum.c,v 1.10 2014/07/13 16:03:10 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 1999. 3 * project 1999.
4 */ 4 */
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60#include <string.h>
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ENUMERATED_NAMES crl_reasons[] = { 63static ENUMERATED_NAMES crl_reasons[] = {
@@ -93,7 +93,7 @@ i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e)
93 strval = ASN1_ENUMERATED_get(e); 93 strval = ASN1_ENUMERATED_get(e);
94 for (enam = method->usr_data; enam->lname; enam++) { 94 for (enam = method->usr_data; enam->lname; enam++) {
95 if (strval == enam->bitnum) 95 if (strval == enam->bitnum)
96 return BUF_strdup(enam->lname); 96 return strdup(enam->lname);
97 } 97 }
98 return i2s_ASN1_ENUMERATED(method, e); 98 return i2s_ASN1_ENUMERATED(method, e);
99} 99}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_purp.c b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
index 03fb427277..b8db8d69a2 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_purp.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_purp.c,v 1.21 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_purp.c,v 1.22 2014/07/13 16:03:10 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 2001. 3 * project 2001.
4 */ 4 */
@@ -227,8 +227,8 @@ X509_PURPOSE_add(int id, int trust, int flags,
227 free(ptmp->sname); 227 free(ptmp->sname);
228 } 228 }
229 /* dup supplied name */ 229 /* dup supplied name */
230 ptmp->name = BUF_strdup(name); 230 ptmp->name = name ? strdup(name) : NULL;
231 ptmp->sname = BUF_strdup(sname); 231 ptmp->sname = sname ? strdup(sname) : NULL;
232 if (!ptmp->name || !ptmp->sname) { 232 if (!ptmp->name || !ptmp->sname) {
233 free(ptmp->name); 233 free(ptmp->name);
234 free(ptmp->sname); 234 free(ptmp->sname);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_utl.c b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
index d9987e32a5..99090f3cd2 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_utl.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_utl.c,v 1.22 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: v3_utl.c,v 1.23 2014/07/13 16:03:10 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. 3 * project.
4 */ 4 */
@@ -87,9 +87,9 @@ X509V3_add_value(const char *name, const char *value,
87 CONF_VALUE *vtmp = NULL; 87 CONF_VALUE *vtmp = NULL;
88 char *tname = NULL, *tvalue = NULL; 88 char *tname = NULL, *tvalue = NULL;
89 89
90 if (name && !(tname = BUF_strdup(name))) 90 if (name && !(tname = strdup(name)))
91 goto err; 91 goto err;
92 if (value && !(tvalue = BUF_strdup(value))) 92 if (value && !(tvalue = strdup(value)))
93 goto err; 93 goto err;
94 if (!(vtmp = malloc(sizeof(CONF_VALUE)))) 94 if (!(vtmp = malloc(sizeof(CONF_VALUE))))
95 goto err; 95 goto err;
@@ -301,7 +301,10 @@ X509V3_parse_list(const char *line)
301 int state; 301 int state;
302 302
303 /* We are going to modify the line so copy it first */ 303 /* We are going to modify the line so copy it first */
304 linebuf = BUF_strdup(line); 304 if ((linebuf = strdup(line)) == NULL) {
305 X509V3err(X509V3_F_X509V3_PARSE_LIST, ERR_R_MALLOC_FAILURE);
306 goto err;
307 }
305 state = HDR_NAME; 308 state = HDR_NAME;
306 ntmp = NULL; 309 ntmp = NULL;
307 310
@@ -632,7 +635,7 @@ append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
632 /* Don't add duplicates */ 635 /* Don't add duplicates */
633 if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) 636 if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
634 return 1; 637 return 1;
635 emtmp = BUF_strdup((char *)email->data); 638 emtmp = strdup((char *)email->data);
636 if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) { 639 if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
637 X509_email_free(*sk); 640 X509_email_free(*sk);
638 *sk = NULL; 641 *sk = NULL;
@@ -686,7 +689,7 @@ a2i_IPADDRESS_NC(const char *ipasc)
686 p = strchr(ipasc, '/'); 689 p = strchr(ipasc, '/');
687 if (!p) 690 if (!p)
688 return NULL; 691 return NULL;
689 iptmp = BUF_strdup(ipasc); 692 iptmp = strdup(ipasc);
690 if (!iptmp) 693 if (!iptmp)
691 return NULL; 694 return NULL;
692 p = iptmp + (p - ipasc); 695 p = iptmp + (p - ipasc);
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index decdda90a3..8a40b758a9 100644
--- a/src/lib/libssl/src/ssl/s3_lib.c
+++ b/src/lib/libssl/src/ssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.70 2014/07/12 22:33:39 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.71 2014/07/13 16:03:10 beck 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 *
@@ -2566,7 +2566,7 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
2566 SSL_R_SSL3_EXT_INVALID_SERVERNAME); 2566 SSL_R_SSL3_EXT_INVALID_SERVERNAME);
2567 return 0; 2567 return 0;
2568 } 2568 }
2569 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) 2569 if ((s->tlsext_hostname = strdup((char *)parg))
2570 == NULL) { 2570 == NULL) {
2571 SSLerr(SSL_F_SSL3_CTRL, 2571 SSLerr(SSL_F_SSL3_CTRL,
2572 ERR_R_INTERNAL_ERROR); 2572 ERR_R_INTERNAL_ERROR);
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index 101da82b56..d1cd418601 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.37 2014/07/12 23:59:11 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.38 2014/07/13 16:03:10 beck 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 *
@@ -367,7 +367,7 @@ ssl_get_new_session(SSL *s, int session)
367 367
368sess_id_done: 368sess_id_done:
369 if (s->tlsext_hostname) { 369 if (s->tlsext_hostname) {
370 ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname); 370 ss->tlsext_hostname = strdup(s->tlsext_hostname);
371 if (ss->tlsext_hostname == NULL) { 371 if (ss->tlsext_hostname == NULL) {
372 SSLerr(SSL_F_SSL_GET_NEW_SESSION, 372 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
373 ERR_R_INTERNAL_ERROR); 373 ERR_R_INTERNAL_ERROR);
diff --git a/src/lib/libssl/src/ssl/t1_lib.c b/src/lib/libssl/src/ssl/t1_lib.c
index 46b47a95b7..d82573fdb6 100644
--- a/src/lib/libssl/src/ssl/t1_lib.c
+++ b/src/lib/libssl/src/ssl/t1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_lib.c,v 1.50 2014/07/12 22:33:39 jsing Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.51 2014/07/13 16:03:10 beck 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 *
@@ -1426,7 +1426,8 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d,
1426 if (!s->hit && tlsext_servername == 1) { 1426 if (!s->hit && tlsext_servername == 1) {
1427 if (s->tlsext_hostname) { 1427 if (s->tlsext_hostname) {
1428 if (s->session->tlsext_hostname == NULL) { 1428 if (s->session->tlsext_hostname == NULL) {
1429 s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname); 1429 s->session->tlsext_hostname =
1430 strdup(s->tlsext_hostname);
1430 1431
1431 if (!s->session->tlsext_hostname) { 1432 if (!s->session->tlsext_hostname) {
1432 *al = SSL_AD_UNRECOGNIZED_NAME; 1433 *al = SSL_AD_UNRECOGNIZED_NAME;
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 101da82b56..d1cd418601 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.37 2014/07/12 23:59:11 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.38 2014/07/13 16:03:10 beck 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 *
@@ -367,7 +367,7 @@ ssl_get_new_session(SSL *s, int session)
367 367
368sess_id_done: 368sess_id_done:
369 if (s->tlsext_hostname) { 369 if (s->tlsext_hostname) {
370 ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname); 370 ss->tlsext_hostname = strdup(s->tlsext_hostname);
371 if (ss->tlsext_hostname == NULL) { 371 if (ss->tlsext_hostname == NULL) {
372 SSLerr(SSL_F_SSL_GET_NEW_SESSION, 372 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
373 ERR_R_INTERNAL_ERROR); 373 ERR_R_INTERNAL_ERROR);
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index 46b47a95b7..d82573fdb6 100644
--- a/src/lib/libssl/t1_lib.c
+++ b/src/lib/libssl/t1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_lib.c,v 1.50 2014/07/12 22:33:39 jsing Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.51 2014/07/13 16:03:10 beck 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 *
@@ -1426,7 +1426,8 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d,
1426 if (!s->hit && tlsext_servername == 1) { 1426 if (!s->hit && tlsext_servername == 1) {
1427 if (s->tlsext_hostname) { 1427 if (s->tlsext_hostname) {
1428 if (s->session->tlsext_hostname == NULL) { 1428 if (s->session->tlsext_hostname == NULL) {
1429 s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname); 1429 s->session->tlsext_hostname =
1430 strdup(s->tlsext_hostname);
1430 1431
1431 if (!s->session->tlsext_hostname) { 1432 if (!s->session->tlsext_hostname) {
1432 *al = SSL_AD_UNRECOGNIZED_NAME; 1433 *al = SSL_AD_UNRECOGNIZED_NAME;