]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
RT3754: check for NULL pointer
authorEmilia Kasper <emilia@openssl.org>
Tue, 1 Sep 2015 14:31:55 +0000 (16:31 +0200)
committerEmilia Kasper <emilia@openssl.org>
Thu, 10 Sep 2015 15:21:23 +0000 (17:21 +0200)
Fix both the caller to error out on malloc failure, as well as the
eventual callee to handle a NULL gracefully.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
crypto/evp/p_lib.c
crypto/evp/pmeth_gn.c

index daa3d57c0279cb8d10b3272eed732a3540105665..f07d7e5e4fe6bb536301e8f39bfc0ab8699fbc9c 100644 (file)
@@ -261,7 +261,7 @@ int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)
 
 int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
 {
-    if (!EVP_PKEY_set_type(pkey, type))
+    if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))
         return 0;
     pkey->pkey.ptr = key;
     return (key != NULL);
index 705801fc0252f3fa47102e45b948ac62e5d24ce2..9416e1ab7215fc46244615a98e74ca6f73f3e3d3 100644 (file)
@@ -96,12 +96,17 @@ int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
         return -1;
     }
 
-    if (!ppkey)
+    if (ppkey == NULL)
         return -1;
 
-    if (!*ppkey)
+    if (*ppkey == NULL)
         *ppkey = EVP_PKEY_new();
 
+    if (*ppkey == NULL) {
+        EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);
+        return -1;
+    }
+
     ret = ctx->pmeth->paramgen(ctx, *ppkey);
     if (ret <= 0) {
         EVP_PKEY_free(*ppkey);