summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2019-10-17 15:45:34 -0400
committerRichard Levitte <levitte@openssl.org>2019-10-17 23:19:59 +0200
commit3d48457478bd61030c370e4090c1462fc4453d81 (patch)
treecf36ad0667881411cb5b02f44411c03e510e12f2
parent8c77d45adab101f10b323de3d59fb47b8f8d3a93 (diff)
downloadopenssl-new-3d48457478bd61030c370e4090c1462fc4453d81.tar.gz
Replace BUF_ string function calls with OPENSSL_ ones
Deprecate the BUF_ string macros Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10207)
-rw-r--r--apps/s_server.c4
-rw-r--r--crypto/bio/bss_acpt.c2
-rw-r--r--crypto/bio/bss_conn.c2
-rw-r--r--crypto/ct/ct_oct.c6
-rw-r--r--include/openssl/buffer.h18
-rw-r--r--ssl/s3_lib.c2
-rw-r--r--ssl/tls_srp.c4
-rw-r--r--test/ossl_shim/ossl_shim.cc4
-rw-r--r--test/sslcorrupttest.c2
9 files changed, 21 insertions, 23 deletions
diff --git a/apps/s_server.c b/apps/s_server.c
index 28937bd80f..ab409db701 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -1010,7 +1010,7 @@ int s_server_main(int argc, char *argv[])
int socket_family = AF_UNSPEC, socket_type = SOCK_STREAM, protocol = 0;
int state = 0, crl_format = FORMAT_PEM, crl_download = 0;
char *host = NULL;
- char *port = BUF_strdup(PORT);
+ char *port = OPENSSL_strdup(PORT);
unsigned char *context = NULL;
OPTION_CHOICE o;
EVP_PKEY *s_key2 = NULL;
@@ -1159,7 +1159,7 @@ int s_server_main(int argc, char *argv[])
#ifdef AF_UNIX
case OPT_UNIX:
socket_family = AF_UNIX;
- OPENSSL_free(host); host = BUF_strdup(opt_arg());
+ OPENSSL_free(host); host = OPENSSL_strdup(opt_arg());
OPENSSL_free(port); port = NULL;
break;
case OPT_UNLINK:
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index 3c2b279b3f..3d2937594e 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -432,7 +432,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
b->init = 1;
} else if (num == 1) {
OPENSSL_free(data->param_serv);
- data->param_serv = BUF_strdup(ptr);
+ data->param_serv = OPENSSL_strdup(ptr);
b->init = 1;
} else if (num == 2) {
data->bind_mode |= BIO_SOCK_NONBLOCK;
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index afcf436749..3c2060cc10 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -411,7 +411,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
OPENSSL_free(hold_service);
} else if (num == 1) {
OPENSSL_free(data->param_service);
- data->param_service = BUF_strdup(ptr);
+ data->param_service = OPENSSL_strdup(ptr);
} else if (num == 2) {
const BIO_ADDR *addr = (const BIO_ADDR *)ptr;
if (ret) {
diff --git a/crypto/ct/ct_oct.c b/crypto/ct/ct_oct.c
index cdab02fdf8..bd8d1bb1df 100644
--- a/crypto/ct/ct_oct.c
+++ b/crypto/ct/ct_oct.c
@@ -101,7 +101,7 @@ SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len)
}
len -= 43;
p++;
- sct->log_id = BUF_memdup(p, CT_V1_HASHLEN);
+ sct->log_id = OPENSSL_memdup(p, CT_V1_HASHLEN);
if (sct->log_id == NULL)
goto err;
sct->log_id_len = CT_V1_HASHLEN;
@@ -115,7 +115,7 @@ SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len)
goto err;
}
if (len2 > 0) {
- sct->ext = BUF_memdup(p, len2);
+ sct->ext = OPENSSL_memdup(p, len2);
if (sct->ext == NULL)
goto err;
}
@@ -132,7 +132,7 @@ SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len)
*in = p + len;
} else {
/* If not V1 just cache encoding */
- sct->sct = BUF_memdup(p, len);
+ sct->sct = OPENSSL_memdup(p, len);
if (sct->sct == NULL)
goto err;
sct->sct_len = len;
diff --git a/include/openssl/buffer.h b/include/openssl/buffer.h
index c3cf216147..49581b826a 100644
--- a/include/openssl/buffer.h
+++ b/include/openssl/buffer.h
@@ -30,16 +30,14 @@ extern "C" {
# include <stddef.h>
# include <sys/types.h>
-/*
- * These names are outdated as of OpenSSL 1.1; a future release
- * will move them to be deprecated.
- */
-# define BUF_strdup(s) OPENSSL_strdup(s)
-# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
-# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
-# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
-# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
-# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
+# if !OPENSSL_API_3
+# define BUF_strdup(s) OPENSSL_strdup(s)
+# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
+# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
+# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
+# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
+# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
+# endif
struct buf_mem_st {
size_t length; /* current number of bytes */
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index a329915ac9..15aeae365e 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -3885,7 +3885,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
srp_password_from_info_cb;
if (ctx->srp_ctx.info != NULL)
OPENSSL_free(ctx->srp_ctx.info);
- if ((ctx->srp_ctx.info = BUF_strdup((char *)parg)) == NULL) {
+ if ((ctx->srp_ctx.info = OPENSSL_strdup((char *)parg)) == NULL) {
SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
return 0;
}
diff --git a/ssl/tls_srp.c b/ssl/tls_srp.c
index d252db33fb..6888bcd4d4 100644
--- a/ssl/tls_srp.c
+++ b/ssl/tls_srp.c
@@ -104,7 +104,7 @@ int SSL_SRP_CTX_init(struct ssl_st *s)
goto err;
}
if ((ctx->srp_ctx.info != NULL) &&
- ((s->srp_ctx.info = BUF_strdup(ctx->srp_ctx.info)) == NULL)) {
+ ((s->srp_ctx.info = OPENSSL_strdup(ctx->srp_ctx.info)) == NULL)) {
SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
goto err;
}
@@ -235,7 +235,7 @@ int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
if (info != NULL) {
if (s->srp_ctx.info)
OPENSSL_free(s->srp_ctx.info);
- if ((s->srp_ctx.info = BUF_strdup(info)) == NULL)
+ if ((s->srp_ctx.info = OPENSSL_strdup(info)) == NULL)
return -1;
}
diff --git a/test/ossl_shim/ossl_shim.cc b/test/ossl_shim/ossl_shim.cc
index ae67fb58ef..ea1ff3a983 100644
--- a/test/ossl_shim/ossl_shim.cc
+++ b/test/ossl_shim/ossl_shim.cc
@@ -288,8 +288,8 @@ static unsigned PskClientCallback(SSL *ssl, const char *hint,
return 0;
}
- BUF_strlcpy(out_identity, config->psk_identity.c_str(),
- max_identity_len);
+ OPENSSL_strlcpy(out_identity, config->psk_identity.c_str(),
+ max_identity_len);
memcpy(out_psk, config->psk.data(), config->psk.size());
return config->psk.size();
}
diff --git a/test/sslcorrupttest.c b/test/sslcorrupttest.c
index bffccc86d2..66f8cd142c 100644
--- a/test/sslcorrupttest.c
+++ b/test/sslcorrupttest.c
@@ -41,7 +41,7 @@ static int tls_corrupt_write(BIO *bio, const char *in, int inl)
char *copy;
if (docorrupt) {
- if (!TEST_ptr(copy = BUF_memdup(in, inl)))
+ if (!TEST_ptr(copy = OPENSSL_memdup(in, inl)))
return 0;
/* corrupt last bit of application data */
copy[inl-1] ^= 1;