Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix bug #67563: mysqli compiled with mysqlnd does not take ipv6 adress as parameter #19750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nielsdos wants to merge 1 commit into php:PHP-8.3
base: PHP-8.3
Choose a base branch
Loading
from nielsdos:fix-67563
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion ext/mysqlnd/mysqlnd_connection.c
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
}
/* }}} */

/* ipv6 addresses have at least two colons, which is how we can differentiate between domain names and addresses */
static bool mysqlnd_fast_is_ipv6_address(const char *s)
{
const char *first_colon = strchr(s, ':');
if (!first_colon) {
return false;
}
return strchr(first_colon + 1, ':') != NULL;
}

/* {{{ mysqlnd_conn_data::get_scheme */
static MYSQLND_STRING
MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING *socket_or_pipe, unsigned int port, bool * unix_socket, bool * named_pipe)
Expand Down Expand Up @@ -542,7 +552,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_
if (!port) {
port = 3306;
}
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);

/* ipv6 addresses are in the format [address]:port */
if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) {
transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port);
} else {
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);
}
}
DBG_INF_FMT("transport=%s", transport.s? transport.s:"OOM");
DBG_RETURN(transport);
Expand Down

AltStyle によって変換されたページ (->オリジナル) /