Skip to content

Commit aa82c9c

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix phpGH-8978: MySQLi: SSL certificate verification fails (port doubled)
2 parents d1018be + 472f2fe commit aa82c9c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ PHP NEWS
2828
- LibXML:
2929
. Fix not thread safe schema/relaxng calls. (SpencerMalone, nielsdos)
3030

31+
- MySQLnd:
32+
. Fixed bug GH-8978 (SSL certificate verification fails (port doubled)).
33+
(nielsdos)
34+
3135
- Opcache:
3236
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
3337
(Arnaud)

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_
557557
if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) {
558558
transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port);
559559
} else {
560-
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);
560+
/* Not ipv6, but could already contain a port number, in which case we should not add an extra port.
561+
* See GH-8978. In a port doubling scenario, the first port would be used so we do the same to keep BC. */
562+
if (strchr(hostname.s, ':')) {
563+
/* TODO: Ideally we should be able to get rid of this workaround in the future. */
564+
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s", hostname.s);
565+
} else {
566+
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);
567+
}
561568
}
562569
}
563570
DBG_INF_FMT("transport=%s", transport.s? transport.s:"OOM");

0 commit comments

Comments
 (0)