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)
This commit is contained in:
Rich Salz 2019-10-17 15:45:34 -04:00 committed by Richard Levitte
parent 8c77d45ada
commit 3d48457478
9 changed files with 21 additions and 23 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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 */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;