From 48f8adac24daf4447c00002bbf9b0f858bc99441 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Sat, 22 Nov 2025 23:56:16 +0800 Subject: [PATCH] Fix GH-20528 regression breaks mysql connexion using an IPv6 address enclosed in square brackets --- php-bug20528.patch | 81 ++++++++++++++++++++++++++++++++++++++++++++++ php.spec | 24 ++++---------- 2 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 php-bug20528.patch diff --git a/php-bug20528.patch b/php-bug20528.patch new file mode 100644 index 0000000..f8a790a --- /dev/null +++ b/php-bug20528.patch @@ -0,0 +1,81 @@ +From 9d71c1e0b60cd152a47528dbe514efc443fce920 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 20 Nov 2025 02:58:45 +0100 +Subject: [PATCH] Fix GH-20528: Regression breaks mysql connexion using an IPv6 + address enclosed in square brackets + +--- + ext/mysqli/tests/mysqli_connect_port.phpt | 31 +++++++++++++++++++++++ + ext/mysqlnd/mysqlnd_connection.c | 17 ++++++++++--- + 2 files changed, 45 insertions(+), 3 deletions(-) + create mode 100644 ext/mysqli/tests/mysqli_connect_port.phpt + +diff --git a/ext/mysqli/tests/mysqli_connect_port.phpt b/ext/mysqli/tests/mysqli_connect_port.phpt +new file mode 100644 +index 0000000000000..cb7fd1d8d1628 +--- /dev/null ++++ b/ext/mysqli/tests/mysqli_connect_port.phpt +@@ -0,0 +1,31 @@ ++--TEST-- ++mysqli_connect() with port in host ++--EXTENSIONS-- ++mysqli ++--SKIPIF-- ++ ++--FILE-- ++ ++Done ++--EXPECTF-- ++Done +diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c +index d8e7304e9665f..8268034e8b798 100644 +--- a/ext/mysqlnd/mysqlnd_connection.c ++++ b/ext/mysqlnd/mysqlnd_connection.c +@@ -553,13 +553,24 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_ + port = 3306; + } + +- /* ipv6 addresses are in the format [address]:port */ + if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) { ++ /* IPv6 without square brackets so without port */ + transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port); + } else { +- /* Not ipv6, but could already contain a port number, in which case we should not add an extra port. ++ char *p; ++ ++ /* IPv6 addresses are in the format [address]:port */ ++ if (hostname.s[0] == '[') { /* IPv6 */ ++ p = strchr(hostname.s, ']'); ++ if (p && p[1] != ':') { ++ p = NULL; ++ } ++ } else { /* IPv4 or name */ ++ p = strchr(hostname.s, ':'); ++ } ++ /* Could already contain a port number, in which case we should not add an extra port. + * See GH-8978. In a port doubling scenario, the first port would be used so we do the same to keep BC. */ +- if (strchr(hostname.s, ':')) { ++ if (p) { + /* TODO: Ideally we should be able to get rid of this workaround in the future. */ + transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s", hostname.s); + } else { diff --git a/php.spec b/php.spec index 680c7c4..31f0920 100644 --- a/php.spec +++ b/php.spec @@ -48,14 +48,6 @@ # OpenSSL2 with argon2 %bcond_without openssl32 -%if 0 -# liburiparser version 0.9.10 required -%bcond_without liburiparser -%else -# use bundled library instead -%bcond_with liburiparser -%endif - # /usr/sbin/apsx with httpd < 2.4 and defined as /usr/bin/apxs with httpd >= 2.4 %{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}} %{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn 2>/dev/null || echo 0-0)}} @@ -74,7 +66,7 @@ Summary: PHP scripting language for creating dynamic web sites Name: php Version: %{upver} -Release: 1 +Release: 2 # All files licensed under PHP version 3.01, except # Zend is licensed under Zend # TSRM is licensed under BSD @@ -133,6 +125,7 @@ Patch47: php-8.4.0-phpinfo.patch # RC Patch # Upstream fixes (100+) +Patch100: php-bug20528.patch # Security fixes (200+) @@ -182,11 +175,7 @@ BuildRequires: libtool-ltdl-devel %if %{with dtrace} BuildRequires: systemtap-sdt-devel %endif -%if %{with liburiparser} -BuildRequires: pkgconfig(liburiparser) >= 0.9.10 -%else Provides: bundled(liburiparser) = 0.9.10 -%endif # used for tests BuildRequires: /usr/bin/ps %if %{with tzdata} @@ -992,9 +981,6 @@ ln -sf ../configure %endif %if %{with libxcrypt} --with-external-libcrypt \ -%endif -%if %{with liburiparser} - --with-external-uriparser \ %endif --with-zlib \ --with-layout=GNU \ @@ -1340,7 +1326,7 @@ install -D -m 644 %{S:14} $RPM_BUILD_ROOT%{_sysconfdir}/nginx/default.d/php.conf TESTCMD="$RPM_BUILD_ROOT%{_bindir}/php --no-php-ini" # Ensure all provided extensions are really there -for mod in core date filter hash json libxml openssl pcntl pcre readline reflection session spl standard zlib +for mod in core date filter hash json lexbor libxml openssl pcntl pcre random readline reflection session sockets spl standard uri zlib do $TESTCMD --modules | grep -i "$mod\$" done @@ -1621,6 +1607,10 @@ systemctl try-restart php-fpm.service >/dev/null 2>&1 || : %{_fileattrsdir}/composer.attr %changelog +* Sat Nov 22 2025 Funda Wang - 8.5.0-2 +- Fix GH-20528 regression breaks mysql connexion using an IPv6 address enclosed + in square brackets (upstream patch) + * Tue Nov 18 2025 Funda Wang - 8.5.0-1 - update to 8.5.0 -- Gitee