diff options
author | Alexander Barkov <bar@mariadb.com> | 2021-10-10 18:42:32 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2021-10-11 17:01:47 +0400 |
commit | 9300b6657752e566a3c72da7ca6eaa8ee052e4e1 (patch) | |
tree | 34429cd3609fd0311500a59141178db6ec450dc0 | |
parent | 5e3e5ccbea2ab90548fc82c5d730dea2c9315a16 (diff) | |
download | mariadb-git-9300b6657752e566a3c72da7ca6eaa8ee052e4e1.tar.gz |
MDEV-24742 Server crashes in Charset::numchars / String::numcharsbb-10.2-bar-MDEV-24742
The crash happened because Item_aes_crypt::val_str() did not
set the character set of the result.
-rw-r--r-- | mysql-test/r/func_str.result | 12 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 16 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 |
3 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 798b4f9ff09..f9346a25151 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -4835,3 +4835,15 @@ DROP TABLE t1; # # End of 10.1 tests # +# +# Start of 10.2 tests +# +# +# MDEV-24742 Server crashes in Charset::numchars / String::numchars +# +SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux'); +NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux') +NULL +# +# End of 10.2 tests +# diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1a59946e97e..366aacb1945 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1932,3 +1932,19 @@ DROP TABLE t1; --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-24742 Server crashes in Charset::numchars / String::numchars +--echo # + +SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux'); + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 26a23b0cb55..e5935178f10 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -338,6 +338,8 @@ String *Item_aes_crypt::val_str(String *str2) rkey, AES_KEY_LENGTH / 8, 0, 0)) { str2->length((uint) aes_length); + DBUG_ASSERT(collation.collation == &my_charset_bin); + str2->set_charset(&my_charset_bin); return str2; } } |