Skip to content

Commit 981f01e

Browse files
committed
Merge branch 'PHP-8.2'
2 parents 45eae90 + d687a1b commit 981f01e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ext/openssl/xp_ssl.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
131131
ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
132132

133+
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
133134
/* Used for IPv6 Address peer verification */
134135
#define EXPAND_IPV6_ADDRESS(_str, _bytes) \
135136
do { \
@@ -144,6 +145,8 @@
144145
_bytes[14] << 8 | _bytes[15] \
145146
); \
146147
} while(0)
148+
#define HAVE_IPV6_SAN 1
149+
#endif
147150

148151
#if PHP_OPENSSL_API_VERSION < 0x10100
149152
static RSA *php_openssl_tmp_rsa_cb(SSL *s, int is_export, int keylength);
@@ -456,16 +459,17 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
456459
GENERAL_NAMES *alt_names = X509_get_ext_d2i(peer, NID_subject_alt_name, 0, 0);
457460
int alt_name_count = sk_GENERAL_NAME_num(alt_names);
458461

459-
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
462+
#ifdef HAVE_IPV6_SAN
460463
/* detect if subject name is an IPv6 address and expand once if required */
461-
char subject_name_ipv6_expanded[40];
462-
unsigned char ipv6[16];
463-
bool subject_name_is_ipv6 = false;
464-
subject_name_ipv6_expanded[0] = 0;
464+
char subject_name_ipv6_expanded[40];
465+
unsigned char ipv6[16];
466+
bool subject_name_is_ipv6 = false;
467+
subject_name_ipv6_expanded[0] = 0;
468+
465469
if (inet_pton(AF_INET6, subject_name, &ipv6)) {
466-
EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6);
467-
subject_name_is_ipv6 = true;
468-
}
470+
EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6);
471+
subject_name_is_ipv6 = true;
472+
}
469473
#endif
470474

471475
for (i = 0; i < alt_name_count; i++) {
@@ -506,7 +510,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
506510
return 1;
507511
}
508512
}
509-
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
513+
#ifdef HAVE_IPV6_SAN
510514
else if (san->d.ip->length == 16 && subject_name_is_ipv6) {
511515
ipbuffer[0] = 0;
512516
EXPAND_IPV6_ADDRESS(ipbuffer, san->d.iPAddress->data);

0 commit comments

Comments
 (0)