Skip to content

Commit 389fb92

Browse files
committed
openssl: Add error checks for CMS_get1_certs() and CMS_get1_crls()
These allocate new stacks and add the certificates to those as clones. So these aren't trivial refcount increases and might fail. Unfortunately, an empty stack also results in a NULL return, so to distinguish an empty stack from a failure we check the error stack.
1 parent 6e87107 commit 389fb92

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

ext/openssl/openssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6677,6 +6677,10 @@ PHP_FUNCTION(openssl_cms_read)
66776677
case NID_pkcs7_signedAndEnveloped:
66786678
certs = CMS_get1_certs(cms);
66796679
crls = CMS_get1_crls(cms);
6680+
if ((!certs || !crls) && ERR_peek_error() != 0) {
6681+
php_openssl_store_errors();
6682+
goto clean_exit;
6683+
}
66806684
break;
66816685
default:
66826686
break;

0 commit comments

Comments
 (0)