Skip to content

Commit a8b7665

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix error check on X509_set_subject_name() Fix crash when ASN1_STRING_to_UTF8() fails
2 parents c4e70a2 + 8b031ea commit a8b7665

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ext/openssl/openssl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,10 @@ PHP_FUNCTION(openssl_csr_sign)
18001800
PHP_OPENSSL_ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial);
18011801
}
18021802

1803-
X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr));
1803+
if (!X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr))) {
1804+
php_openssl_store_errors();
1805+
goto cleanup;
1806+
}
18041807

18051808
if (cert == NULL) {
18061809
cert = new_cert;

ext/openssl/xp_ssl.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@
128128
#define GET_VER_OPT_LONG(_name, _num) \
129129
if (GET_VER_OPT(_name)) _num = zval_get_long(val)
130130

131-
/* Used for peer verification in windows */
132-
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
133-
ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
134-
135131
#ifdef HAVE_IPV6
136132
/* Used for IPv6 Address peer verification */
137133
#define EXPAND_IPV6_ADDRESS(_str, _bytes) \
@@ -474,7 +470,10 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
474470
GENERAL_NAME *san = sk_GENERAL_NAME_value(alt_names, i);
475471

476472
if (san->type == GEN_DNS) {
477-
ASN1_STRING_to_UTF8(&cert_name, san->d.dNSName);
473+
if (ASN1_STRING_to_UTF8(&cert_name, san->d.dNSName) < 0) {
474+
/* TODO: warn ? */
475+
continue;
476+
}
478477
if ((size_t)ASN1_STRING_length(san->d.dNSName) != strlen((const char*)cert_name)) {
479478
OPENSSL_free(cert_name);
480479
/* prevent null-byte poisoning*/

0 commit comments

Comments
 (0)