Skip to content

Commit dd60911

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/mysqlnd/mysqlnd_connection.c

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

0 commit comments

Comments
 (0)