@@ -79,11 +79,15 @@ mysqlnd_run_authentication(
79
79
struct st_mysqlnd_authentication_plugin * auth_plugin = conn -> m -> fetch_auth_plugin_by_name (requested_protocol );
80
80
81
81
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
+ }
85
90
}
86
- DBG_INF ("plugin found" );
87
91
88
92
{
89
93
zend_uchar * switch_to_auth_protocol_data = NULL ;
@@ -108,10 +112,13 @@ mysqlnd_run_authentication(
108
112
109
113
DBG_INF_FMT ("salt(%d)=[%.*s]" , plugin_data_len , plugin_data_len , plugin_data );
110
114
/* 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
+
115
122
if (conn -> error_info -> error_no ) {
116
123
goto end ;
117
124
}
0 commit comments