Skip to content

Commit 1c98955

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
2 parents 6237bcd + e3cf72b commit 1c98955

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

ext/mysqlnd/mysqlnd_auth.c

+15-8
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ mysqlnd_run_authentication(
7979
struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(requested_protocol);
8080

8181
if (!auth_plugin) {
82-
php_error_docref(NULL, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol);
83-
SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method unknown to the client");
84-
goto end;
82+
if (first_call) {
83+
mnd_pefree(requested_protocol, FALSE);
84+
requested_protocol = mnd_pestrdup(MYSQLND_DEFAULT_AUTH_PROTOCOL, FALSE);
85+
} else {
86+
php_error_docref(NULL, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol);
87+
SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method unknown to the client");
88+
goto end;
89+
}
8590
}
86-
DBG_INF("plugin found");
8791

8892
{
8993
zend_uchar * switch_to_auth_protocol_data = NULL;
@@ -108,10 +112,13 @@ mysqlnd_run_authentication(
108112

109113
DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data);
110114
/* The data should be allocated with malloc() */
111-
scrambled_data =
112-
auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
113-
plugin_data, plugin_data_len, session_options,
114-
conn->protocol_frame_codec->data, mysql_flags);
115+
if (auth_plugin) {
116+
scrambled_data =
117+
auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
118+
plugin_data, plugin_data_len, session_options,
119+
conn->protocol_frame_codec->data, mysql_flags);
120+
}
121+
115122
if (conn->error_info->error_no) {
116123
goto end;
117124
}

0 commit comments

Comments
 (0)