Skip to content

Commit fef7741

Browse files
committed
Fix crash in openssl_x509_parse() when X509_NAME_oneline() fails
The X509_NAME_oneline() function can return NULL, which will cause a crash when the string length is computed via add_assoc_string().
1 parent d9cbc31 commit fef7741

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ext/openssl/openssl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,11 @@ PHP_FUNCTION(openssl_x509_parse)
21342134

21352135
subject_name = X509_get_subject_name(cert);
21362136
cert_name = X509_NAME_oneline(subject_name, NULL, 0);
2137+
if (cert_name == NULL) {
2138+
php_openssl_store_errors();
2139+
goto err;
2140+
}
2141+
21372142
add_assoc_string(return_value, "name", cert_name);
21382143
OPENSSL_free(cert_name);
21392144

0 commit comments

Comments
 (0)