diff options
author | Loganaden Velvindron <loganaden@gmail.com> | 2015-04-22 17:16:30 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-04-22 18:18:59 +0200 |
commit | 8031d26b0cc7fb277288b106dc4850adf4d77a23 (patch) | |
tree | f974b5111aad33bdac273bd67fadd91fe6635b0b /crypto/mem.c | |
parent | SSL_CIPHER lookup functions. (diff) | |
download | openssl-8031d26b0cc7fb277288b106dc4850adf4d77a23.tar.xz openssl-8031d26b0cc7fb277288b106dc4850adf4d77a23.zip |
Fix CRYPTO_strdup
The function CRYPTO_strdup (aka OPENSSL_strdup) fails to check the return
value from CRYPTO_malloc to see if it is NULL before attempting to use it.
This patch adds a NULL check.
RT3786
Signed-off-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 37b0cf936744d9edb99b5dd82cae78a7eac6ad60)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 20d21389c8b6f5b754573ffb6a4dc4f3986f2ca4)
Diffstat (limited to 'crypto/mem.c')
-rw-r--r-- | crypto/mem.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/mem.c b/crypto/mem.c index d05936211c..2251d57fb3 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -364,6 +364,9 @@ char *CRYPTO_strdup(const char *str, const char *file, int line) { char *ret = CRYPTO_malloc(strlen(str) + 1, file, line); + if (ret == NULL) + return NULL; + strcpy(ret, str); return ret; } |