Skip to content

Commit 94127c5

Browse files
committed
Fix GH-11440: authentication to a sha256_password account fails over SSL
This is similar to bug #78680, but that bug wasn't really fixed in all places. This is the only remaining place. Closes GH-11444.
1 parent 6e468bb commit 94127c5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ PHP NEWS
1919
- FFI:
2020
. Fix leaking definitions when using FFI::cdef()->new(...). (ilutov)
2121

22+
- MySQLnd:
23+
. Fixed bug GH-11440 (authentication to a sha256_password account fails over
24+
SSL). (nielsdos)
25+
2226
- Opcache:
2327
. Fixed bug GH-11715 (opcache.interned_strings_buffer either has no effect or
2428
opcache_get_status() / phpinfo() is wrong). (nielsdos)

ext/mysqlnd/mysqlnd_auth.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,12 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
912912
if (conn->vio->data->ssl) {
913913
DBG_INF("simple clear text under SSL");
914914
/* clear text under SSL */
915-
*auth_data_len = passwd_len;
916-
ret = malloc(passwd_len);
915+
/* NUL termination byte required: https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_authentication_methods_clear_text_password.html
916+
* (this is similar to bug #78680, but now as GH-11440) */
917+
*auth_data_len = passwd_len + 1;
918+
ret = malloc(passwd_len + 1);
917919
memcpy(ret, passwd, passwd_len);
920+
ret[passwd_len] = '\0';
918921
} else {
919922
*auth_data_len = 0;
920923
server_public_key = mysqlnd_sha256_get_rsa_key(conn, session_options, pfc_data);

0 commit comments

Comments
 (0)