-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-13452: Fixed handshake response [mysqlnd] #13470
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
#include "mysqlnd_auth.h" | ||
#include "mysqlnd_wireprotocol.h" | ||
#include "mysqlnd_debug.h" | ||
#include "mysqlnd_charset.h" | ||
|
||
|
||
/* {{{ mysqlnd_command::set_option */ | ||
|
@@ -642,13 +643,12 @@ MYSQLND_METHOD(mysqlnd_command, handshake)(MYSQLND_CONN_DATA * const conn, const | |
conn->protocol_version = greet_packet.protocol_version; | ||
conn->server_version = mnd_pestrdup(greet_packet.server_version, conn->persistent); | ||
|
||
conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no); | ||
if (!conn->greet_charset) { | ||
char * msg; | ||
mnd_sprintf(&msg, 0, "Server sent charset (%d) unknown to the client. Please, report to the developers", greet_packet.charset_no); | ||
SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, msg); | ||
mnd_sprintf_free(msg); | ||
goto err; | ||
const MYSQLND_CHARSET *read_charset = mysqlnd_find_charset_nr(greet_packet.charset_no); | ||
if (!read_charset) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look closely at So, checking for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Saki. That's why I feel that the way the current code works is correct. It raises an error whenever an unexpected charset is provided. 0 doesn't have any special meaning here. What you are suggesting would probably be ok, but not ideal. So I would suggest using the two constant values as a fallback if we receive an unknown value from the server. Then we can think if we can drop this feature from mysqlnd in a major release. Maybe 9.0 would be good to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for confirmation.
If I didn't make a mistake, it should already work as a fallback like you mention. Two constants are used when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree. Initially I was thinking of using 8.4, but 9.x might be ideal. |
||
greet_packet.charset_no = conn->m->get_server_version(conn) >= 50500 ? MYSQLND_UTF8_MB4_DEFAULT_ID : MYSQLND_UTF8_MB3_DEFAULT_ID; | ||
conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no); | ||
} else { | ||
conn->greet_charset = read_charset; | ||
} | ||
|
||
conn->server_capabilities = greet_packet.server_capabilities; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MariaDB 11.3 Docker images have been patched - MariaDB/mariadb-docker@d7a950d
but the GH-13452 can be tested using 11.3.1-rc image - https://hub.docker.com/layers/library/mariadb/11.3.1-rc/images/sha256-f37b1ba4f15fb90679f8f85fd7300815ef4c5ff7ada668bccbdff33e2ad8ecd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note can also test by placing
--character-set-collations=utf8mb4=uca1400_ai_ci
as the command on the 11.3+ image to enforce the setting.