Commit 8ad3c615 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting...

MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting CHARACTER_SET_RESULTS to NULL and running any invalid SQL | Binary_string::copy_printable_hhhh

The old code did not take into account that
thd->variables.character_set_results can be NULL.
parent 7bcaa541
...@@ -49,3 +49,14 @@ ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\04 ...@@ -49,3 +49,14 @@ ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\04
disconnect con1; disconnect con1;
connection default; connection default;
End of 5.5 tests End of 5.5 tests
#
# MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting CHARACTER_SET_RESULTS to NULL and running any invalid SQL | Binary_string::copy_printable_hhhh
#
SET NAMES latin1;
SET @@CHARACTER_SET_RESULTS=NULL;
a;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a' at line 1
SHOW WARNINGS;
Level Code Message
Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a' at line 1
SET NAMES latin1;
...@@ -58,3 +58,14 @@ disconnect con1; ...@@ -58,3 +58,14 @@ disconnect con1;
connection default; connection default;
--echo End of 5.5 tests --echo End of 5.5 tests
--echo #
--echo # MDEV-22130 SHOW WARNINGS will SIGSEGV 10.5 optimized build after setting CHARACTER_SET_RESULTS to NULL and running any invalid SQL | Binary_string::copy_printable_hhhh
--echo #
SET NAMES latin1;
SET @@CHARACTER_SET_RESULTS=NULL;
--error ER_PARSE_ERROR
a;
SHOW WARNINGS;
SET NAMES latin1;
...@@ -1194,7 +1194,7 @@ bool Protocol::store_warning(const char *from, size_t length) ...@@ -1194,7 +1194,7 @@ bool Protocol::store_warning(const char *from, size_t length)
{ {
BinaryStringBuffer<MYSQL_ERRMSG_SIZE> tmp; BinaryStringBuffer<MYSQL_ERRMSG_SIZE> tmp;
CHARSET_INFO *cs= thd->variables.character_set_results; CHARSET_INFO *cs= thd->variables.character_set_results;
if (cs == &my_charset_bin) if (!cs || cs == &my_charset_bin)
cs= system_charset_info; cs= system_charset_info;
if (tmp.copy_printable_hhhh(cs, system_charset_info, from, length)) if (tmp.copy_printable_hhhh(cs, system_charset_info, from, length))
return net_store_data((const uchar*)"", 0); return net_store_data((const uchar*)"", 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment