aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-12-16 16:12:24 -0500
committerRich Salz <rsalz@openssl.org>2015-12-16 16:14:49 -0500
commit7644a9aef8932ed4d1c3f25ed776c997702982be (patch)
treed8f1e7fca20ad12683a1e2e52c92b6999ada23a6 /crypto
parente4cf866322a4549c55153f9f135f9dadf4d3fc31 (diff)
downloadopenssl-7644a9aef8932ed4d1c3f25ed776c997702982be.zip
openssl-7644a9aef8932ed4d1c3f25ed776c997702982be.tar.gz
openssl-7644a9aef8932ed4d1c3f25ed776c997702982be.tar.bz2
Rename some BUF_xxx to OPENSSL_xxx
Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} Add #define's for the old names. Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/Makefile9
-rw-r--r--crypto/asn1/a_time.c6
-rw-r--r--crypto/asn1/ameth_lib.c4
-rw-r--r--crypto/asn1/asn_mime.c8
-rw-r--r--crypto/bio/b_dump.c14
-rw-r--r--crypto/bio/b_sock.c2
-rw-r--r--crypto/bio/bss_acpt.c2
-rw-r--r--crypto/bio/bss_conn.c10
-rw-r--r--crypto/bio/bss_file.c10
-rw-r--r--crypto/buffer/Makefile12
-rw-r--r--crypto/buffer/buf_err.c3
-rw-r--r--crypto/buffer/buf_str.c137
-rw-r--r--crypto/conf/conf_def.c4
-rw-r--r--crypto/conf/conf_mod.c14
-rw-r--r--crypto/cpt_err.c1
-rw-r--r--crypto/dh/dh_ameth.c6
-rw-r--r--crypto/dh/dh_pmeth.c2
-rw-r--r--crypto/dso/dso_lib.c4
-rw-r--r--crypto/ec/ec_pmeth.c2
-rw-r--r--crypto/engine/eng_dyn.c6
-rw-r--r--crypto/err/err.c2
-rw-r--r--crypto/evp/e_chacha20_poly1305.c2
-rw-r--r--crypto/evp/evp_pbe.c2
-rw-r--r--crypto/lock.c2
-rw-r--r--crypto/mem.c9
-rw-r--r--crypto/mem_dbg.c2
-rw-r--r--crypto/o_str.c81
-rw-r--r--crypto/objects/obj_dat.c6
-rw-r--r--crypto/ocsp/ocsp_lib.c10
-rw-r--r--crypto/pem/pem_lib.c12
-rw-r--r--crypto/rand/Makefile6
-rw-r--r--crypto/rand/rand_egd.c4
-rw-r--r--crypto/rand/randfile.c12
-rw-r--r--crypto/rsa/rsa_pmeth.c2
-rw-r--r--crypto/srp/srp_vfy.c10
-rw-r--r--crypto/store/str_lib.c4
-rw-r--r--crypto/store/str_meth.c2
-rw-r--r--crypto/ui/ui_lib.c30
-rw-r--r--crypto/x509/x509_trs.c2
-rw-r--r--crypto/x509/x509_vpm.c8
-rw-r--r--crypto/x509v3/v3_addr.c6
-rw-r--r--crypto/x509v3/v3_asid.c2
-rw-r--r--crypto/x509v3/v3_enum.c2
-rw-r--r--crypto/x509v3/v3_info.c6
-rw-r--r--crypto/x509v3/v3_purp.c4
-rw-r--r--crypto/x509v3/v3_utl.c14
46 files changed, 215 insertions, 283 deletions
diff --git a/crypto/Makefile b/crypto/Makefile
index b2cf528..43cb71f 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -202,8 +202,13 @@ o_init.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
o_init.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
o_init.o: ../include/openssl/safestack.h ../include/openssl/stack.h
o_init.o: ../include/openssl/symhacks.h o_init.c
-o_str.o: ../e_os.h ../include/internal/o_str.h ../include/openssl/e_os2.h
-o_str.o: ../include/openssl/opensslconf.h o_str.c
+o_str.o: ../e_os.h ../include/internal/o_str.h ../include/openssl/bio.h
+o_str.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
+o_str.o: ../include/openssl/e_os2.h ../include/openssl/err.h
+o_str.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
+o_str.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+o_str.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+o_str.o: ../include/openssl/symhacks.h include/internal/cryptlib.h o_str.c
o_time.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
o_time.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
o_time.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c
index ff82beb..c5e632e 100644
--- a/crypto/asn1/a_time.c
+++ b/crypto/asn1/a_time.c
@@ -139,11 +139,11 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
str = (char *)ret->data;
/* Work out the century and prepend */
if (t->data[0] >= '5')
- BUF_strlcpy(str, "19", newlen);
+ OPENSSL_strlcpy(str, "19", newlen);
else
- BUF_strlcpy(str, "20", newlen);
+ OPENSSL_strlcpy(str, "20", newlen);
- BUF_strlcat(str, (char *)t->data, newlen);
+ OPENSSL_strlcat(str, (char *)t->data, newlen);
return ret;
}
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index 05f0a80..85115bc 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -285,13 +285,13 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
if (info) {
- ameth->info = BUF_strdup(info);
+ ameth->info = OPENSSL_strdup(info);
if (!ameth->info)
goto err;
}
if (pem_str) {
- ameth->pem_str = BUF_strdup(pem_str);
+ ameth->pem_str = OPENSSL_strdup(pem_str);
if (!ameth->pem_str)
goto err;
}
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c
index 5369099..ed9d8d6 100644
--- a/crypto/asn1/asn_mime.c
+++ b/crypto/asn1/asn_mime.c
@@ -829,7 +829,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
int c;
if (name) {
- if ((tmpname = BUF_strdup(name)) == NULL)
+ if ((tmpname = OPENSSL_strdup(name)) == NULL)
return NULL;
for (p = tmpname; *p; p++) {
c = (unsigned char)*p;
@@ -840,7 +840,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
}
}
if (value) {
- if ((tmpval = BUF_strdup(value)) == NULL)
+ if ((tmpval = OPENSSL_strdup(value)) == NULL)
goto err;
for (p = tmpval; *p; p++) {
c = (unsigned char)*p;
@@ -872,7 +872,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
int c;
MIME_PARAM *mparam = NULL;
if (name) {
- tmpname = BUF_strdup(name);
+ tmpname = OPENSSL_strdup(name);
if (!tmpname)
goto err;
for (p = tmpname; *p; p++) {
@@ -884,7 +884,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
}
}
if (value) {
- tmpval = BUF_strdup(value);
+ tmpval = OPENSSL_strdup(value);
if (!tmpval)
goto err;
}
diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c
index 55792b9..3d005e3 100644
--- a/crypto/bio/b_dump.c
+++ b/crypto/bio/b_dump.c
@@ -104,20 +104,20 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
- BUF_strlcpy(buf, str, sizeof buf);
+ OPENSSL_strlcpy(buf, str, sizeof buf);
BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len) {
- BUF_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof buf);
} else {
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
BIO_snprintf(tmp, sizeof tmp, "%02x%c", ch,
j == 7 ? '-' : ' ');
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
}
}
- BUF_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof buf);
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len)
break;
@@ -131,9 +131,9 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
? os_toebcdic[ch]
: '.');
#endif
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
}
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
/*
* if this is the last call then update the ddt_dump thing so that we
* will move the selection point in the debug window
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index e536eda..cc09072 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -402,7 +402,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
if (BIO_sock_init() != 1)
return ((int)INVALID_SOCKET);
- if ((str = BUF_strdup(host)) == NULL)
+ if ((str = OPENSSL_strdup(host)) == NULL)
return ((int)INVALID_SOCKET);
h = p = NULL;
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index c549c87..f65ee1a 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -350,7 +350,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
if (num == 0) {
b->init = 1;
OPENSSL_free(data->param_addr);
- data->param_addr = BUF_strdup(ptr);
+ data->param_addr = OPENSSL_strdup(ptr);
} else if (num == 1) {
data->accept_nbio = (ptr != NULL);
} else if (num == 2) {
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index ba009aa..929656c 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -149,7 +149,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
break;
}
OPENSSL_free(c->param_port);
- c->param_port = BUF_strdup(p);
+ c->param_port = OPENSSL_strdup(p);
}
}
@@ -455,10 +455,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
b->init = 1;
if (num == 0) {
OPENSSL_free(data->param_hostname);
- data->param_hostname = BUF_strdup(ptr);
+ data->param_hostname = OPENSSL_strdup(ptr);
} else if (num == 1) {
OPENSSL_free(data->param_port);
- data->param_port = BUF_strdup(ptr);
+ data->param_port = OPENSSL_strdup(ptr);
} else if (num == 2) {
char buf[16];
unsigned char *p = ptr;
@@ -466,14 +466,14 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
p[0], p[1], p[2], p[3]);
OPENSSL_free(data->param_hostname);
- data->param_hostname = BUF_strdup(buf);
+ data->param_hostname = OPENSSL_strdup(buf);
memcpy(&(data->ip[0]), ptr, 4);
} else if (num == 3) {
char buf[DECIMAL_SIZE(int) + 1];
BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
OPENSSL_free(data->param_port);
- data->param_port = BUF_strdup(buf);
+ data->param_port = OPENSSL_strdup(buf);
data->port = *(int *)ptr;
}
}
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index 7692ee2..c09a9a9 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -367,15 +367,15 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
b->shutdown = (int)num & BIO_CLOSE;
if (num & BIO_FP_APPEND) {
if (num & BIO_FP_READ)
- BUF_strlcpy(p, "a+", sizeof p);
+ OPENSSL_strlcpy(p, "a+", sizeof p);
else
- BUF_strlcpy(p, "a", sizeof p);
+ OPENSSL_strlcpy(p, "a", sizeof p);
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
- BUF_strlcpy(p, "r+", sizeof p);
+ OPENSSL_strlcpy(p, "r+", sizeof p);
else if (num & BIO_FP_WRITE)
- BUF_strlcpy(p, "w", sizeof p);
+ OPENSSL_strlcpy(p, "w", sizeof p);
else if (num & BIO_FP_READ)
- BUF_strlcpy(p, "r", sizeof p);
+ OPENSSL_strlcpy(p, "r", sizeof p);
else {
BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);
ret = 0;
diff --git a/crypto/buffer/Makefile b/crypto/buffer/Makefile
index f9d52fe..e0b6ffd 100644
--- a/crypto/buffer/Makefile
+++ b/crypto/buffer/Makefile
@@ -15,8 +15,8 @@ CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile
LIB=$(TOP)/libcrypto.a
-LIBSRC= buffer.c buf_str.c buf_err.c
-LIBOBJ= buffer.o buf_str.o buf_err.o
+LIBSRC= buffer.c buf_err.c
+LIBOBJ= buffer.o buf_err.o
SRC= $(LIBSRC)
@@ -67,14 +67,6 @@ buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
buf_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
buf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
buf_err.o: buf_err.c
-buf_str.o: ../../e_os.h ../../include/openssl/bio.h
-buf_str.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-buf_str.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
-buf_str.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
-buf_str.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-buf_str.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-buf_str.o: ../../include/openssl/symhacks.h ../include/internal/cryptlib.h
-buf_str.o: buf_str.c
buffer.o: ../../e_os.h ../../include/openssl/bio.h
buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
diff --git a/crypto/buffer/buf_err.c b/crypto/buffer/buf_err.c
index 34671aa..e126edd 100644
--- a/crypto/buffer/buf_err.c
+++ b/crypto/buffer/buf_err.c
@@ -70,12 +70,9 @@
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason)
static ERR_STRING_DATA BUF_str_functs[] = {
- {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"},
{ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"},
{ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"},
{ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"},
- {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"},
- {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"},
{0, NULL}
};
diff --git a/crypto/buffer/buf_str.c b/crypto/buffer/buf_str.c
deleted file mode 100644
index 1f3e8a4..0000000
--- a/crypto/buffer/buf_str.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* crypto/buffer/buffer.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include <limits.h>
-#include "internal/cryptlib.h"
-#include <openssl/buffer.h>
-
-size_t BUF_strnlen(const char *str, size_t maxlen)
-{
- const char *p;
-
- for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
-
- return p - str;
-}
-
-char *BUF_strdup(const char *str)
-{
- if (str == NULL)
- return NULL;
- return BUF_strndup(str, strlen(str));
-}
-
-char *BUF_strndup(const char *str, size_t siz)
-{
- char *ret;
-
- if (str == NULL)
- return NULL;
-
- siz = BUF_strnlen(str, siz);
-
- if (siz >= INT_MAX)
- return NULL;
-
- ret = OPENSSL_malloc(siz + 1);
- if (ret == NULL) {
- BUFerr(BUF_F_BUF_STRNDUP, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
-
- memcpy(ret, str, siz);
- ret[siz] = '\0';
-
- return (ret);
-}
-
-void *BUF_memdup(const void *data, size_t siz)
-{
- void *ret;
-
- if (data == NULL || siz >= INT_MAX)
- return NULL;
-
- ret = OPENSSL_malloc(siz);
- if (ret == NULL) {
- BUFerr(BUF_F_BUF_MEMDUP, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
- return memcpy(ret, data, siz);
-}
-
-size_t BUF_strlcpy(char *dst, const char *src, size_t size)
-{
- size_t l = 0;
- for (; size > 1 && *src; size--) {
- *dst++ = *src++;
- l++;
- }
- if (size)
- *dst = '\0';
- return l + strlen(src);
-}
-
-size_t BUF_strlcat(char *dst, const char *src, size_t size)
-{
- size_t l = 0;
- for (; size > 0 && *dst; size--, dst++)
- l++;
- return l + BUF_strlcpy(dst, src, size);
-}
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index 1ff49aa..ac07405 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -223,7 +223,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
goto err;
}
- section = BUF_strdup("default");
+ section = OPENSSL_strdup("default");
if (section == NULL) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
@@ -366,7 +366,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
}
- BUF_strlcpy(v->name, pname, strlen(pname) + 1);
+ OPENSSL_strlcpy(v->name, pname, strlen(pname) + 1);
if (!str_copy(conf, psection, &(v->value), start))
goto err;
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index c1fbb60..4fafded 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -286,7 +286,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
return NULL;
tmod->dso = dso;
- tmod->name = BUF_strdup(name);
+ tmod->name = OPENSSL_strdup(name);
tmod->init = ifunc;
tmod->finish = ffunc;
@@ -340,8 +340,8 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
goto err;
imod->pmod = pmod;
- imod->name = BUF_strdup(name);
- imod->value = BUF_strdup(value);
+ imod->name = OPENSSL_strdup(name);
+ imod->value = OPENSSL_strdup(value);
imod->usr_data = NULL;
if (!imod->name || !imod->value)
@@ -525,7 +525,7 @@ char *CONF_get1_default_config_file(void)
file = getenv("OPENSSL_CONF");
if (file)
- return BUF_strdup(file);
+ return OPENSSL_strdup(file);
len = strlen(X509_get_default_cert_area());
#ifndef OPENSSL_SYS_VMS
@@ -537,11 +537,11 @@ char *CONF_get1_default_config_file(void)
if (file == NULL)
return NULL;
- BUF_strlcpy(file, X509_get_default_cert_area(), len + 1);
+ OPENSSL_strlcpy(file, X509_get_default_cert_area(), len + 1);
#ifndef OPENSSL_SYS_VMS
- BUF_strlcat(file, "/", len + 1);
+ OPENSSL_strlcat(file, "/", len + 1);
#endif
- BUF_strlcat(file, OPENSSL_CONF, len + 1);
+ OPENSSL_strlcat(file, OPENSSL_CONF, len + 1);
return file;
}
diff --git a/crypto/cpt_err.c b/crypto/cpt_err.c
index b8d3fa4..af505ac 100644
--- a/crypto/cpt_err.c
+++ b/crypto/cpt_err.c
@@ -75,6 +75,7 @@ static ERR_STRING_DATA CRYPTO_str_functs[] = {
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX), "CRYPTO_get_ex_new_index"},
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID), "CRYPTO_get_new_dynlockid"},
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID), "CRYPTO_get_new_lockid"},
+ {ERR_FUNC(CRYPTO_F_CRYPTO_MEMDUP), "CRYPTO_memdup"},
{ERR_FUNC(CRYPTO_F_CRYPTO_NEW_EX_DATA), "CRYPTO_new_ex_data"},
{ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA), "CRYPTO_set_ex_data"},
{ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX), "DEF_ADD_INDEX"},
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c
index 7a3d923..64eaf4c 100644
--- a/crypto/dh/dh_ameth.c
+++ b/crypto/dh/dh_ameth.c
@@ -482,7 +482,7 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942)
to->seed = NULL;
to->seedlen = 0;
if (from->seed) {
- to->seed = BUF_memdup(from->seed, from->seedlen);
+ to->seed = OPENSSL_memdup(from->seed, from->seedlen);
if (!to->seed)
return 0;
to->seedlen = from->seedlen;
@@ -770,7 +770,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
if (ukm) {
dukmlen = ASN1_STRING_length(ukm);
- dukm = BUF_memdup(ASN1_STRING_data(ukm), dukmlen);
+ dukm = OPENSSL_memdup(ASN1_STRING_data(ukm), dukmlen);
if (!dukm)
goto err;
}
@@ -914,7 +914,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
if (ukm) {
dukmlen = ASN1_STRING_length(ukm);
- dukm = BUF_memdup(ASN1_STRING_data(ukm), dukmlen);
+ dukm = OPENSSL_memdup(ASN1_STRING_data(ukm), dukmlen);
if (!dukm)
goto err;
}
diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
index 1e12c3e..a760ff5 100644
--- a/crypto/dh/dh_pmeth.c
+++ b/crypto/dh/dh_pmeth.c
@@ -134,7 +134,7 @@ static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
return 0;
dctx->kdf_md = sctx->kdf_md;
if (dctx->kdf_ukm) {
- dctx->kdf_ukm = BUF_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
+ dctx->kdf_ukm = OPENSSL_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
dctx->kdf_ukmlen = sctx->kdf_ukmlen;
}
dctx->kdf_outlen = sctx->kdf_outlen;
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index 17d1732..56e7657 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -353,7 +353,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
return (0);
}
- BUF_strlcpy(copied, filename, strlen(filename) + 1);
+ OPENSSL_strlcpy(copied, filename, strlen(filename) + 1);
OPENSSL_free(dso->filename);
dso->filename = copied;
return (1);
@@ -402,7 +402,7 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- BUF_strlcpy(result, filename, strlen(filename) + 1);
+ OPENSSL_strlcpy(result, filename, strlen(filename) + 1);
}
return (result);
}
diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c
index cbdf4e2..bcb5063 100644
--- a/crypto/ec/ec_pmeth.c
+++ b/crypto/ec/ec_pmeth.c
@@ -124,7 +124,7 @@ static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
dctx->kdf_md = sctx->kdf_md;
dctx->kdf_outlen = sctx->kdf_outlen;
if (sctx->kdf_ukm) {
- dctx->kdf_ukm = BUF_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
+ dctx->kdf_ukm = OPENSSL_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
if (!dctx->kdf_ukm)
return 0;
} else
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c
index aed50f6..23f01cf 100644
--- a/crypto/engine/eng_dyn.c
+++ b/crypto/engine/eng_dyn.c
@@ -352,7 +352,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
p = NULL;
OPENSSL_free(ctx->DYNAMIC_LIBNAME);
if (p)
- ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
+ ctx->DYNAMIC_LIBNAME = OPENSSL_strdup(p);
else
ctx->DYNAMIC_LIBNAME = NULL;
return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
@@ -365,7 +365,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
p = NULL;
OPENSSL_free(ctx->engine_id);
if (p)
- ctx->engine_id = BUF_strdup(p);
+ ctx->engine_id = OPENSSL_strdup(p);
else
ctx->engine_id = NULL;
return (ctx->engine_id ? 1 : 0);
@@ -392,7 +392,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
return 0;
}
{
- char *tmp_str = BUF_strdup(p);
+ char *tmp_str = OPENSSL_strdup(p);
if (!tmp_str) {
ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE);
return 0;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index b7ca3de..236f8ac 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -968,7 +968,7 @@ void ERR_add_error_vdata(int num, va_list args)
}
str = p;
}
- BUF_strlcat(str, a, (size_t)s + 1);
+ OPENSSL_strlcat(str, a, (size_t)s + 1);
}
}
ERR_set_error_data(str, ERR_TXT_MALLOCED | ERR_TXT_STRING);
diff --git a/crypto/evp/e_chacha20_poly1305.c b/crypto/evp/e_chacha20_poly1305.c
index 0d80f95..c3c72a1 100644
--- a/crypto/evp/e_chacha20_poly1305.c
+++ b/crypto/evp/e_chacha20_poly1305.c
@@ -383,7 +383,7 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
case EVP_CTRL_COPY:
if (actx) {
if ((((EVP_CIPHER_CTX *)ptr)->cipher_data =
- BUF_memdup(actx,sizeof(*actx) + Poly1305_ctx_size()))
+ OPENSSL_memdup(actx,sizeof(*actx) + Poly1305_ctx_size()))
== NULL) {
EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_COPY_ERROR);
return 0;
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c
index e5b1739..563634e 100644
--- a/crypto/evp/evp_pbe.c
+++ b/crypto/evp/evp_pbe.c
@@ -141,7 +141,7 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
char obj_tmp[80];
EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM);
if (!pbe_obj)
- BUF_strlcpy(obj_tmp, "NULL", sizeof obj_tmp);
+ OPENSSL_strlcpy(obj_tmp, "NULL", sizeof obj_tmp);
else
i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp);
diff --git a/crypto/lock.c b/crypto/lock.c
index d24527a..f337c0d 100644
--- a/crypto/lock.c
+++ b/crypto/lock.c
@@ -215,7 +215,7 @@ int CRYPTO_get_new_lockid(char *name)
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
return (0);
}
- if ((str = BUF_strdup(name)) == NULL) {
+ if ((str = OPENSSL_strdup(name)) == NULL) {
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
return (0);
}
diff --git a/crypto/mem.c b/crypto/mem.c
index 33a76d2..83a1547 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -321,15 +321,6 @@ void *CRYPTO_zalloc(int num, const char *file, int line)
return ret;
}
-char *CRYPTO_strdup(const char *str, const char *file, int line)
-{
- char *ret = CRYPTO_malloc(strlen(str) + 1, file, line);
-
- if (ret != NULL)
- strcpy(ret, str);
- return ret;
-}
-
void *CRYPTO_realloc(void *str, int num, const char *file, int line)
{
void *ret = NULL;
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index c2fe8af..9a48410 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -704,7 +704,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
buf_len = 128 - 3;
} else {
- BUF_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
+ OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
buf_len = strlen(buf);
}
BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
diff --git a/crypto/o_str.c b/crypto/o_str.c
index f2f9404..e96f62a 100644
--- a/crypto/o_str.c
+++ b/crypto/o_str.c
@@ -58,7 +58,10 @@
*/
#include <ctype.h>
+#include <limits.h>
#include <e_os.h>
+#include <openssl/crypto.h>
+#include "internal/cryptlib.h"
#include "internal/o_str.h"
#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \
@@ -114,3 +117,81 @@ int OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
return ret;
}
+
+char *CRYPTO_strdup(const char *str, const char* file, int line)
+{
+ char *ret;
+
+ if (str == NULL)
+ return NULL;
+ ret = CRYPTO_malloc(strlen(str) + 1, file, line);
+ if (ret != NULL)
+ strcpy(ret, str);
+ return ret;
+}
+
+char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)
+{
+ const char *cp;
+ size_t maxlen;
+ char *ret;
+
+ if (str == NULL)
+ return NULL;
+
+ /* Get length. */
+ for (cp = str, maxlen = s; maxlen-- != 0 && *cp != '\0'; ++cp)
+ continue;
+ maxlen = cp - str;
+
+ ret = CRYPTO_malloc(maxlen + 1, file, line);
+ if (ret) {
+ memcpy(ret, str, maxlen);
+ ret[maxlen] = '\0';
+ }
+ return ret;
+}
+
+void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)
+{
+ void *ret;
+
+ if (data == NULL || siz >= INT_MAX)
+ return NULL;
+
+ ret = CRYPTO_malloc(siz, file, line);
+ if (ret == NULL) {
+ CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
+ return memcpy(ret, data, siz);
+}
+
+size_t OPENSSL_strnlen(const char *str, size_t maxlen)
+{
+ const char *p;
+
+ for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
+
+ return p - str;
+}
+
+size_t OPENSSL_strlcpy(char *dst, const char *src, size_t size)
+{
+ size_t l = 0;
+ for (; size > 1 && *src; size--) {
+ *dst++ = *src++;
+ l++;
+ }
+ if (size)
+ *dst = '\0';
+ return l + strlen(src);
+}
+
+size_t OPENSSL_strlcat(char *dst, const char *src, size_t size)
+{
+ size_t l = 0;
+ for (; size > 0 && *dst; size--, dst++)
+ l++;
+ return l + OPENSSL_strlcpy(dst, src, size);
+}
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index e8a6b13..bda9556 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -484,7 +484,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
s = OBJ_nid2sn(nid);
if (s) {
if (buf)
- BUF_strlcpy(buf, s, buf_len);
+ OPENSSL_strlcpy(buf, s, buf_len);
n = strlen(s);
return n;
}
@@ -558,7 +558,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
*buf = '\0';
buf_len--;
}
- BUF_strlcpy(buf, bndec, buf_len);
+ OPENSSL_strlcpy(buf, bndec, buf_len);
if (i > buf_len) {
buf += buf_len;
buf_len = 0;
@@ -574,7 +574,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
BIO_snprintf(tbuf, sizeof tbuf, ".%lu", l);
i = strlen(tbuf);
if (buf && (buf_len > 0)) {
- BUF_strlcpy(buf, tbuf, buf_len);
+ OPENSSL_strlcpy(buf, tbuf, buf_len);
if (i > buf_len) {
buf += buf_len;
buf_len = 0;
diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c
index 9784294..092cc37 100644
--- a/crypto/ocsp/ocsp_lib.c
+++ b/crypto/ocsp/ocsp_lib.c
@@ -183,7 +183,7 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
*ppath = NULL;
/* dup the buffer since we are going to mess with it */
- buf = BUF_strdup(url);
+ buf = OPENSSL_strdup(url);
if (!buf)
goto mem_err;
@@ -217,9 +217,9 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
p = strchr(p, '/');
if (!p)
- *ppath = BUF_strdup("/");
+ *ppath = OPENSSL_strdup("/");
else {
- *ppath = BUF_strdup(p);
+ *ppath = OPENSSL_strdup(p);
/* Set start of path to 0 so hostname is valid */
*p = '\0';
}
@@ -244,11 +244,11 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
port = p + 1;
}
- *pport = BUF_strdup(port);
+ *pport = OPENSSL_strdup(port);
if (!*pport)
goto mem_err;
- *phost = BUF_strdup(host);
+ *phost = OPENSSL_strdup(host);
if (!*phost)
goto mem_err;
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 42a8583..465e2ee 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -134,9 +134,9 @@ void PEM_proc_type(char *buf, int type)
else
str = "BAD-TYPE";
- BUF_strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE);
- BUF_strlcat(buf, str, PEM_BUFSIZE);
- BUF_strlcat(buf, "\n", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, str, PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "\n", PEM_BUFSIZE);
}
void PEM_dek_info(char *buf, const char *type, int len, char *str)
@@ -145,9 +145,9 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str)
long i;
int j;
- BUF_strlcat(buf, "DEK-Info: ", PEM_BUFSIZE);
- BUF_strlcat(buf, type, PEM_BUFSIZE);
- BUF_strlcat(buf, ",", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "DEK-Info: ", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, type, PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, ",", PEM_BUFSIZE);
j = strlen(buf);
if (j + (len * 2) + 1 > PEM_BUFSIZE)
return;
diff --git a/crypto/rand/Makefile b/crypto/rand/Makefile
index adcbb82..bc8c624 100644
--- a/crypto/rand/Makefile
+++ b/crypto/rand/Makefile
@@ -72,9 +72,11 @@ md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h
-rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
+rand_egd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rand_egd.o: ../../include/openssl/opensslconf.h
-rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
+rand_egd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
+rand_egd.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_egd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rand_egd.o: rand_egd.c
rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c
index d062dd6..ea3621c 100644
--- a/crypto/rand/rand_egd.c
+++ b/crypto/rand/rand_egd.c
@@ -54,9 +54,9 @@
*
*/
+#include <openssl/crypto.h>
#include <openssl/e_os2.h>
#include <openssl/rand.h>
-#include <openssl/buffer.h>
/*-
* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
@@ -144,7 +144,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
addr.sun_family = AF_UNIX;
if (strlen(path) >= sizeof(addr.sun_path))
return (-1);
- BUF_strlcpy(addr.sun_path, path, sizeof addr.sun_path);
+ OPENSSL_strlcpy(addr.sun_path, path, sizeof addr.sun_path);
len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index e154646..a1b0c4d 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -294,7 +294,7 @@ const char *RAND_file_name(char *buf, size_t size)
if (OPENSSL_issetugid() == 0)
s = getenv("RANDFILE");
if (s != NULL && *s && strlen(s) + 1 < size) {
- if (BUF_strlcpy(buf, s, size) >= size)
+ if (OPENSSL_strlcpy(buf, s, size) >= size)
return NULL;
} else {
if (OPENSSL_issetugid() == 0)
@@ -305,11 +305,11 @@ const char *RAND_file_name(char *buf, size_t size)
}
#endif
if (s && *s && strlen(s) + strlen(RFILE) + 2 < size) {
- BUF_strlcpy(buf, s, size);
+ OPENSSL_strlcpy(buf, s, size);
#ifndef OPENSSL_SYS_VMS
- BUF_strlcat(buf, "/", size);
+ OPENSSL_strlcat(buf, "/", size);
#endif
- BUF_strlcat(buf, RFILE, size);
+ OPENSSL_strlcat(buf, RFILE, size);
} else
buf[0] = '\0'; /* no file name */
}
@@ -324,11 +324,11 @@ const char *RAND_file_name(char *buf, size_t size)
*/
if (!buf[0])
- if (BUF_strlcpy(buf, "/dev/arandom", size) >= size) {
+ if (OPENSSL_strlcpy(buf, "/dev/arandom", size) >= size) {
return (NULL);
}
if (stat(buf, &sb) == -1)
- if (BUF_strlcpy(buf, "/dev/arandom", size) >= size) {
+ if (OPENSSL_strlcpy(buf, "/dev/arandom", size) >= size) {
return (NULL);
}
#endif
diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c
index 8c8e0e8..f5f8c1f 100644
--- a/crypto/rsa/rsa_pmeth.c
+++ b/crypto/rsa/rsa_pmeth.c
@@ -128,7 +128,7 @@ static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
dctx->mgf1md = sctx->mgf1md;
if (sctx->oaep_label) {
OPENSSL_free(dctx->oaep_label);
- dctx->oaep_label = BUF_memdup(sctx->oaep_label, sctx->oaep_labellen);
+ dctx->oaep_label = OPENSSL_memdup(sctx->oaep_label, sctx->oaep_labellen);
if (!dctx->oaep_label)
return 0;
dctx->oaep_labellen = sctx->oaep_labellen;
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
index 1be68f2..65c763c 100644
--- a/crypto/srp/srp_vfy.c
+++ b/crypto/srp/srp_vfy.c
@@ -220,9 +220,9 @@ static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,
static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
const char *info)
{
- if (id != NULL && NULL == (vinfo->id = BUF_strdup(id)))
+ if (id != NULL && NULL == (vinfo->id = OPENSSL_strdup(id)))
return 0;
- return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
+ return (info == NULL || NULL != (vinfo->info = OPENSSL_strdup(info)));
}
static 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)
vb->default_g = NULL;
vb->default_N = NULL;
vb->seed_key = NULL;
- if ((seed_key != NULL) && (vb->seed_key = BUF_strdup(seed_key)) == NULL) {
+ if ((seed_key != NULL) && (vb->seed_key = OPENSSL_strdup(seed_key)) == NULL) {
sk_SRP_user_pwd_free(vb->users_pwd);
sk_SRP_gN_cache_free(vb->gN_cache);
OPENSSL_free(vb);
@@ -289,7 +289,7 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch)
if (newgN == NULL)
return NULL;
- if ((newgN->b64_bn = BUF_strdup(ch)) == NULL)
+ if ((newgN->b64_bn = OPENSSL_strdup(ch)) == NULL)
goto err;
len = t_fromb64(tmp, ch);
@@ -394,7 +394,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL)
goto err;
- if ((gN->id = BUF_strdup(pp[DB_srpid])) == NULL
+ if ((gN->id = OPENSSL_strdup(pp[DB_srpid])) == NULL
|| (gN->N = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
== NULL
|| (gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
diff --git a/crypto/store/str_lib.c b/crypto/store/str_lib.c
index d5ecdbd..301d0c0 100644
--- a/crypto/store/str_lib.c
+++ b/crypto/store/str_lib.c
@@ -1305,7 +1305,7 @@ int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
return 0;
}
if (!ATTR_IS_SET(attrs, code)) {
- if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size)))
+ if ((attrs->values[code].cstring = OPENSSL_strndup(cstr, cstr_size)))
return 1;
STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, ERR_R_MALLOC_FAILURE);
return 0;
@@ -1324,7 +1324,7 @@ int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
}
if (!ATTR_IS_SET(attrs, code)) {
if ((attrs->values[code].sha1string =
- (unsigned char *)BUF_memdup(sha1str, sha1str_size)))
+ (unsigned char *)OPENSSL_memdup(sha1str, sha1str_size)))
return 1;
STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, ERR_R_MALLOC_FAILURE);
return 0;
diff --git a/crypto/store/str_meth.c b/crypto/store/str_meth.c
index f9ce8bb..5e0f4bd 100644
--- a/crypto/store/str_meth.c
+++ b/crypto/store/str_meth.c
@@ -66,7 +66,7 @@ STORE_METHOD *STORE_create_method(char *name)
STORE_METHOD *store_method = OPENSSL_zalloc(sizeof(*store_method));
if (store_method != NULL)
- store_method->name = BUF_strdup(name);
+ store_method->name = OPENSSL_strdup(name);
return store_method;
}
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index d2ac28b..ea3ec13 100644
--- a/crypto/ui/ui_lib.c
+++ b/crypto/ui/ui_lib.c
@@ -238,7 +238,7 @@ int UI_dup_input_string(UI *ui, const char *prompt, int flags,
char *prompt_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
return 0;
@@ -266,7 +266,7 @@ int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
char *prompt_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE);
return -1;
@@ -297,7 +297,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
char *cancel_chars_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
@@ -305,7 +305,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
}
if (action_desc) {
- action_desc_copy = BUF_strdup(action_desc);
+ action_desc_copy = OPENSSL_strdup(action_desc);
if (action_desc_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
@@ -313,7 +313,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
}
if (ok_chars) {
- ok_chars_copy = BUF_strdup(ok_chars);
+ ok_chars_copy = OPENSSL_strdup(ok_chars);
if (ok_chars_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
@@ -321,7 +321,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
}
if (cancel_chars) {
- cancel_chars_copy = BUF_strdup(cancel_chars);
+ cancel_chars_copy = OPENSSL_strdup(cancel_chars);
if (cancel_chars_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
@@ -350,7 +350,7 @@ int UI_dup_info_string(UI *ui, const char *text)
char *text_copy = NULL;
if (text) {
- text_copy = BUF_strdup(text);
+ text_copy = OPENSSL_strdup(text);
if (text_copy == NULL) {
UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE);
return -1;
@@ -372,7 +372,7 @@ int UI_dup_error_string(UI *ui, const char *text)
char *text_copy = NULL;
if (text) {
- text_copy = BUF_strdup(text);
+ text_copy = OPENSSL_strdup(text);
if (text_copy == NULL) {
UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE);
return -1;
@@ -405,13 +405,13 @@ char *UI_construct_prompt(UI *ui, const char *object_desc,
prompt = OPENSSL_malloc(len + 1);
if (prompt == NULL)
return NULL;
- BUF_strlcpy(prompt, prompt1, len + 1);
- BUF_strlcat(prompt, object_desc, len + 1);
+ OPENSSL_strlcpy(prompt, prompt1, len + 1);
+ OPENSSL_strlcat(prompt, object_desc, len + 1);
if (object_name) {
- BUF_strlcat(prompt, prompt2, len + 1);
- BUF_strlcat(prompt, object_name, len + 1);
+ OPENSSL_strlcat(prompt, prompt2, len + 1);
+ OPENSSL_strlcat(prompt, object_name, len + 1);
}
- BUF_strlcat(prompt, prompt3, len + 1);
+ OPENSSL_strlcat(prompt, prompt3, len + 1);
}
return prompt;
}
@@ -575,7 +575,7 @@ UI_METHOD *UI_create_method(char *name)
UI_METHOD *ui_method = OPENSSL_zalloc(sizeof(*ui_method));
if (ui_method != NULL)
- ui_method->name = BUF_strdup(name);
+ ui_method->name = OPENSSL_strdup(name);
return ui_method;
}
@@ -822,7 +822,7 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
return -1;
}
- BUF_strlcpy(uis->result_buf, result,
+ OPENSSL_strlcpy(uis->result_buf, result,
uis->_.string_data.result_maxsize + 1);
break;
case UIT_BOOLEAN:
diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c
index 6e3616e..27ee475 100644
--- a/crypto/x509/x509_trs.c
+++ b/crypto/x509/x509_trs.c
@@ -201,7 +201,7 @@ int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
if (trtmp->flags & X509_TRUST_DYNAMIC_NAME)
OPENSSL_free(trtmp->name);
/* dup supplied name */
- if ((trtmp->name = BUF_strdup(name)) == NULL) {
+ if ((trtmp->name = OPENSSL_strdup(name)) == NULL) {
X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c
index 0188114..2a15f82 100644
--- a/crypto/x509/x509_vpm.c
+++ b/crypto/x509/x509_vpm.c
@@ -106,7 +106,7 @@ static int int_x509_param_set_hosts(X509_VERIFY_PARAM *vpm, int mode,
if (name == NULL || namelen == 0)
return 1;
- copy = BUF_strndup(name, namelen);
+ copy = OPENSSL_strndup(name, namelen);
if (copy == NULL)
return 0;
@@ -308,10 +308,10 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
void *tmp;
if (src) {
if (srclen == 0) {
- tmp = BUF_strdup(src);
+ tmp = OPENSSL_strdup(src);
srclen = strlen(src);
} else
- tmp = BUF_memdup(src, srclen);
+ tmp = OPENSSL_memdup(src, srclen);
if (!tmp)
return 0;
} else {
@@ -328,7 +328,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
{
OPENSSL_free(param->name);
- param->name = BUF_strdup(name);
+ param->name = OPENSSL_strdup(name);
if (param->name)
return 1;
return 0;
diff --git a/crypto/x509v3/v3_addr.c b/crypto/x509v3/v3_addr.c
index f4a3bcb..13aa7a8 100644
--- a/crypto/x509v3/v3_addr.c
+++ b/crypto/x509v3/v3_addr.c
@@ -980,7 +980,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
length = length_from_afi(afi);
/*
- * Handle SAFI, if any, and BUF_strdup() so we can null-terminate
+ * Handle SAFI, if any, and OPENSSL_strdup() so we can null-terminate
* the other input values.
*/
if (safi != NULL) {
@@ -992,9 +992,9 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
goto err;
}
t += strspn(t, " \t");
- s = BUF_strdup(t);
+ s = OPENSSL_strdup(t);
} else {
- s = BUF_strdup(val->value);
+ s = OPENSSL_strdup(val->value);
}
if (s == NULL) {
X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/x509v3/v3_asid.c b/crypto/x509v3/v3_asid.c
index af527eb..3e10d7e 100644
--- a/crypto/x509v3/v3_asid.c
+++ b/crypto/x509v3/v3_asid.c
@@ -619,7 +619,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
goto err;
}
} else {
- char *s = BUF_strdup(val->value);
+ char *s = OPENSSL_strdup(val->value);
if (s == NULL) {
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
goto err;
diff --git a/crypto/x509v3/v3_enum.c b/crypto/x509v3/v3_enum.c
index d2f895d..dcdd0c6 100644
--- a/crypto/x509v3/v3_enum.c
+++ b/crypto/x509v3/v3_enum.c
@@ -95,7 +95,7 @@ char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e)
strval = ASN1_ENUMERATED_get(e);
for (enam = method->usr_data; enam->lname; enam++) {
if (strval == enam->bitnum)
- return BUF_strdup(enam->lname);
+ return OPENSSL_strdup(enam->lname);
}
return i2s_ASN1_ENUMERATED(method, e);
}
diff --git a/crypto/x509v3/v3_info.c b/crypto/x509v3/v3_info.c
index 4e38ad3..f8888c2 100644
--- a/crypto/x509v3/v3_info.c
+++ b/crypto/x509v3/v3_info.c
@@ -131,9 +131,9 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
ERR_R_MALLOC_FAILURE);
return NULL;
}
- BUF_strlcpy(ntmp, objtmp, nlen);
- BUF_strlcat(ntmp, " - ", nlen);
- BUF_strlcat(ntmp, vtmp->name, nlen);
+ OPENSSL_strlcpy(ntmp, objtmp, nlen);
+ OPENSSL_strlcat(ntmp, " - ", nlen);
+ OPENSSL_strlcat(ntmp, vtmp->name, nlen);
OPENSSL_free(vtmp->name);
vtmp->name = ntmp;
diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c
index 90b3abc..3724e66 100644
--- a/crypto/x509v3/v3_purp.c
+++ b/crypto/x509v3/v3_purp.c
@@ -225,8 +225,8 @@ int X509_PURPOSE_add(int id, int trust, int flags,
OPENSSL_free(ptmp->sname);
}
/* dup supplied name */
- ptmp->name = BUF_strdup(name);
- ptmp->sname = BUF_strdup(sname);
+ ptmp->name = OPENSSL_strdup(name);
+ ptmp->sname = OPENSSL_strdup(sname);
if (!ptmp->name || !ptmp->sname) {
X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
return 0;
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 8481749..c9e74f4 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -86,9 +86,9 @@ int X509V3_add_value(const char *name, const char *value,
CONF_VALUE *vtmp = NULL;
char *tname = NULL, *tvalue = NULL;
- if (name && (tname = BUF_strdup(name)) == NULL)
+ if (name && (tname = OPENSSL_strdup(name)) == NULL)
goto err;
- if (value && (tvalue = BUF_strdup(value)) == NULL)
+ if (value && (tvalue = OPENSSL_strdup(value)) == NULL)
goto err;
if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL)
goto err;
@@ -296,7 +296,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
char *linebuf;
int state;
/* We are going to modify the line so copy it first */
- linebuf = BUF_strdup(line);
+ linebuf = OPENSSL_strdup(line);
if (linebuf == NULL) {
X509V3err(X509V3_F_X509V3_PARSE_LIST, ERR_R_MALLOC_FAILURE);
goto err;
@@ -617,7 +617,7 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
/* Don't add duplicates */
if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
return 1;
- emtmp = BUF_strdup((char *)email->data);
+ emtmp = OPENSSL_strdup((char *)email->data);
if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
X509_email_free(*sk);
*sk = NULL;
@@ -899,7 +899,7 @@ static int do_check_string(ASN1_STRING *a, int cmp_type, equal_fn equal,
else if (a->length == (int)blen && !memcmp(a->data, b, blen))
rv = 1;
if (rv > 0 && peername)
- *peername = BUF_strndup((char *)a->data, a->length);
+ *peername = OPENSSL_strndup((char *)a->data, a->length);
} else {
int astrlen;
unsigned char *astr;
@@ -913,7 +913,7 @@ static int do_check_string(ASN1_STRING *a, int cmp_type, equal_fn equal,
}
rv = equal(astr, astrlen, (unsigned char *)b, blen, flags);
if (rv > 0 && peername)
- *peername = BUF_strndup((char *)astr, astrlen);
+ *peername = OPENSSL_strndup((char *)astr, astrlen);
OPENSSL_free(astr);
}
return rv;
@@ -1099,7 +1099,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
p = strchr(ipasc, '/');
if (!p)
return NULL;
- iptmp = BUF_strdup(ipasc);
+ iptmp = OPENSSL_strdup(ipasc);
if (!iptmp)
return NULL;
p = iptmp + (p - ipasc);