[openssl-dev] [openssl.org #3700] [PATCH] remove CRYPTO_strdup, switch callers to BUF_strdup

Cristian Rodríguez via RT rt at openssl.org
Fri Feb 13 14:08:12 UTC 2015


No need to a keep a duplicate API.
---
 crypto/crypto.h      | 1 -
 crypto/jpake/jpake.c | 5 +++--
 crypto/mem.c         | 8 --------
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/crypto/crypto.h b/crypto/crypto.h
index 9762398..7dd2223 100644
--- a/crypto/crypto.h
+++ b/crypto/crypto.h
@@ -366,7 +366,6 @@ int CRYPTO_is_mem_check_on(void);
 # define is_MemCheck_on() CRYPTO_is_mem_check_on()
 
 # define OPENSSL_malloc(num)     CRYPTO_malloc((int)num,__FILE__,__LINE__)
-# define OPENSSL_strdup(str)     CRYPTO_strdup((str),__FILE__,__LINE__)
 # define OPENSSL_realloc(addr,num) \
         CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
 # define OPENSSL_realloc_clean(addr,old_num,num) \
diff --git a/crypto/jpake/jpake.c b/crypto/jpake/jpake.c
index eb6654d..2492c1d 100644
--- a/crypto/jpake/jpake.c
+++ b/crypto/jpake/jpake.c
@@ -2,6 +2,7 @@
 #include <openssl/crypto.h>
 #include <openssl/sha.h>
 #include <openssl/err.h>
+#include <openssl/buffer.h>
 #include <memory.h>
 #include <string.h>
 
@@ -74,8 +75,8 @@ static void JPAKE_CTX_init(JPAKE_CTX *ctx, const char *name,
                            const BIGNUM *g, const BIGNUM *q,
                            const BIGNUM *secret)
 {
-    ctx->p.name = OPENSSL_strdup(name);
-    ctx->p.peer_name = OPENSSL_strdup(peer_name);
+    ctx->p.name = BUF_strdup(name);
+    ctx->p.peer_name = BUF_strdup(peer_name);
     ctx->p.p = BN_dup(p);
     ctx->p.g = BN_dup(g);
     ctx->p.q = BN_dup(q);
diff --git a/crypto/mem.c b/crypto/mem.c
index d059362..5173098 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -360,14 +360,6 @@ void *CRYPTO_malloc(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);
-
-    strcpy(ret, str);
-    return ret;
-}
-
 void *CRYPTO_realloc(void *str, int num, const char *file, int line)
 {
     void *ret = NULL;
-- 
2.2.2




More information about the openssl-dev mailing list