Skip to content

mysqlnd_conn_data::get_scheme needs socket_or_pipe by reference #1723

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions ext/mysqlnd/mysqlnd_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,29 +534,29 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
}
/* }}} */

/* {{{ mysqlnd_conn_data::connect */
/* {{{ 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, zend_bool * unix_socket, zend_bool * named_pipe)
MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING *socket_or_pipe, unsigned int port, zend_bool * unix_socket, zend_bool * named_pipe)
{
MYSQLND_STRING transport;
DBG_ENTER("mysqlnd_conn_data::get_scheme");
#ifndef PHP_WIN32
if (hostname.l == sizeof("localhost") - 1 && !strncasecmp(hostname.s, "localhost", hostname.l)) {
DBG_INF_FMT("socket=%s", socket_or_pipe.s? socket_or_pipe.s:"n/a");
if (!socket_or_pipe.s) {
socket_or_pipe.s = "/tmp/mysql.sock";
socket_or_pipe.l = strlen(socket_or_pipe.s);
DBG_INF_FMT("socket=%s", socket_or_pipe->s? socket_or_pipe->s:"n/a");
if (!socket_or_pipe->s) {
socket_or_pipe->s = "/tmp/mysql.sock";
socket_or_pipe->l = strlen(socket_or_pipe->s);
}
transport.l = mnd_sprintf(&transport.s, 0, "unix://%s", socket_or_pipe.s);
transport.l = mnd_sprintf(&transport.s, 0, "unix://%s", socket_or_pipe->s);
*unix_socket = TRUE;
#else
if (hostname.l == sizeof(".") - 1 && hostname.s[0] == '.') {
/* named pipe in socket */
if (!socket_or_pipe.s) {
socket_or_pipe.s = "\\\\.\\pipe\\MySQL";
socket_or_pipe.l = strlen(socket_or_pipe.s);
if (!socket_or_pipe->s) {
socket_or_pipe->s = "\\\\.\\pipe\\MySQL";
socket_or_pipe->l = strlen(socket_or_pipe->s);
}
transport.l = mnd_sprintf(&transport.s, 0, "pipe://%s", socket_or_pipe.s);
transport.l = mnd_sprintf(&transport.s, 0, "pipe://%s", socket_or_pipe->s);
*named_pipe = TRUE;
#endif
} else {
Expand Down Expand Up @@ -657,7 +657,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
mysql_flags |= CLIENT_CONNECT_WITH_DB;
}

transport = conn->m->get_scheme(conn, hostname, socket_or_pipe, port, &unix_socket, &named_pipe);
transport = conn->m->get_scheme(conn, hostname, &socket_or_pipe, port, &unix_socket, &named_pipe);

mysql_flags = conn->m->get_updated_connect_flags(conn, mysql_flags);

Expand Down
2 changes: 1 addition & 1 deletion ext/mysqlnd/mysqlnd_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ typedef enum_func_status (*func_mysqlnd_conn_data__set_client_option_2d)(MYSQLND
typedef size_t (*func_mysqlnd_conn_data__negotiate_client_api_capabilities)(MYSQLND_CONN_DATA * const conn, const size_t flags);
typedef size_t (*func_mysqlnd_conn_data__get_client_api_capabilities)(const MYSQLND_CONN_DATA * const conn);

typedef MYSQLND_STRING (*func_mysqlnd_conn_data__get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING socket_or_pipe, unsigned int port, zend_bool * unix_socket, zend_bool * named_pipe);
typedef MYSQLND_STRING (*func_mysqlnd_conn_data__get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING *socket_or_pipe, unsigned int port, zend_bool * unix_socket, zend_bool * named_pipe);



Expand Down