summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2018-09-07 09:04:59 +1000
committerPauli <paul.dale@oracle.com>2018-09-07 09:04:59 +1000
commita6465b3f8557f69e84e7d8e097f9c45ba4479dd6 (patch)
tree2e8ddd2da67fc990db19291a4c2673709e3c1123 /crypto
parent82eba370daeb6d80b01b521d9e2963451487f0cb (diff)
Avoid SEGV when giving X509_sign a NULL private key.
Put a NULL check back in to avoid dereferencing the NULL pointer. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7146)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/pmeth_lib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 6a0fc81f1f..ef923fdc5e 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -106,6 +106,8 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
const EVP_PKEY_METHOD *pmeth;
if (id == -1) {
+ if (pkey == NULL)
+ return 0;
id = pkey->type;
}
#ifndef OPENSSL_NO_ENGINE
@@ -151,7 +153,7 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
ret->pmeth = pmeth;
ret->operation = EVP_PKEY_OP_UNDEFINED;
ret->pkey = pkey;
- if (pkey)
+ if (pkey != NULL)
EVP_PKEY_up_ref(pkey);
if (pmeth->init) {