Skip to content

Commit fb5d478

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix crash in openssl_x509_parse() when X509_NAME_oneline() fails Fix crash when in openssl_x509_parse() when i2s_ASN1_INTEGER() fails
2 parents c8c9ff6 + 2c08d9a commit fb5d478

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/openssl/openssl.c

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

10331033
subject_name = X509_get_subject_name(cert);
10341034
cert_name = X509_NAME_oneline(subject_name, NULL, 0);
1035+
if (cert_name == NULL) {
1036+
php_openssl_store_errors();
1037+
goto err;
1038+
}
1039+
10351040
add_assoc_string(return_value, "name", cert_name);
10361041
OPENSSL_free(cert_name);
10371042

@@ -1064,6 +1069,12 @@ PHP_FUNCTION(openssl_x509_parse)
10641069
}
10651070

10661071
str_serial = i2s_ASN1_INTEGER(NULL, asn1_serial);
1072+
/* Can return NULL on error or memory allocation failure */
1073+
if (!str_serial) {
1074+
php_openssl_store_errors();
1075+
goto err;
1076+
}
1077+
10671078
add_assoc_string(return_value, "serialNumber", str_serial);
10681079
OPENSSL_free(str_serial);
10691080

0 commit comments

Comments
 (0)