diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-04-12 11:19:21 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2021-04-14 16:05:00 +1000 |
commit | 5c107243877121f84037a5aaf19457f87458e8ed (patch) | |
tree | 8b3ef6e620890f5c1cb4ec1e1cdad9ca74c9888e /crypto/ocsp | |
parent | 46eee7104d77f9d303e06a398febdc60fd014d33 (diff) |
Add some additional NULL checks to prevent segfaults.
Fixes #14809
PR #14752 attempted to pass the libctx, propq in a few places related to
X509 signing. There were a few places that needed additional NULL checks so that they behavethe same as they did before.
OCSP_basic_sign() was changed to call EVP_DigestSignInit_ex() which passed the parameter EVP_MD_name(dgst). Since dgst can be NULL EVP_MD_name() was segfaulting.
Adding an additional NULL check EVP_MD_name() resolves this issue.
The other NULL checks are required to produce errors rather than
segfaults if the certificate is NULL.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14826)
Diffstat (limited to 'crypto/ocsp')
-rw-r--r-- | crypto/ocsp/ocsp_srv.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/ocsp/ocsp_srv.c b/crypto/ocsp/ocsp_srv.c index 4187446e1c..1475bb0f7e 100644 --- a/crypto/ocsp/ocsp_srv.c +++ b/crypto/ocsp/ocsp_srv.c @@ -278,6 +278,8 @@ int OCSP_RESPID_set_by_key_ex(OCSP_RESPID *respid, X509 *cert, int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert) { + if (cert == NULL) + return 0; return OCSP_RESPID_set_by_key_ex(respid, cert, cert->libctx, cert->propq); } @@ -319,5 +321,7 @@ int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx, int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert) { + if (cert == NULL) + return 0; return OCSP_RESPID_match_ex(respid, cert, cert->libctx, cert->propq); } |