From: Loganaden Velvindron Date: Wed, 22 Apr 2015 15:16:30 +0000 (+0100) Subject: Fix CRYPTO_strdup X-Git-Tag: OpenSSL_1_0_2b~110 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6e5d13076503e9ec7f1c2c690339f99284b7d283;p=oweals%2Fopenssl.git 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 (cherry picked from commit 37b0cf936744d9edb99b5dd82cae78a7eac6ad60) Reviewed-by: Rich Salz (cherry picked from commit 20d21389c8b6f5b754573ffb6a4dc4f3986f2ca4) --- diff --git a/crypto/mem.c b/crypto/mem.c index 2ce3e89487..fdad49b76e 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -365,6 +365,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; }