Skip to content

Commit 04c5cdf

Browse files
author
Varun Gupta
committed
MDEV-22836: Server crashes in err_conv / ErrBuff::set_str
The issue here is charset for Sort_param::tmp_buffer is cleared when bzero is done for Sort_param. Make sure to set the charset explicitly in the constructor for tmp_buffer.
1 parent 89a3330 commit 04c5cdf

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

mysql-test/main/order_by.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,4 +3955,14 @@ ORDER BY surname_first ASC LIMIT 1 OFFSET 1;
39553955
name surname_first
39563956
Charles Dickens Dickens, Charles
39573957
DROP TABLE t1;
3958+
#
3959+
# MDEV-22836: Server crashes in err_conv / ErrBuff::set_str
3960+
#
3961+
CREATE TABLE t1 (a INT);
3962+
INSERT INTO t1 VALUES (0),(1);
3963+
SELECT * FROM t1 ORDER BY CONVERT(AES_ENCRYPT(1,a), CHAR(4));
3964+
a
3965+
1
3966+
0
3967+
DROP TABLE t1;
39583968
# End of 10.5 tests

mysql-test/main/order_by.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,4 +2454,15 @@ ORDER BY surname_first ASC LIMIT 1 OFFSET 1;
24542454

24552455
DROP TABLE t1;
24562456

2457+
--echo #
2458+
--echo # MDEV-22836: Server crashes in err_conv / ErrBuff::set_str
2459+
--echo #
2460+
2461+
CREATE TABLE t1 (a INT);
2462+
INSERT INTO t1 VALUES (0),(1);
2463+
--disable_warnings
2464+
SELECT * FROM t1 ORDER BY CONVERT(AES_ENCRYPT(1,a), CHAR(4));
2465+
--enable_warnings
2466+
DROP TABLE t1;
2467+
24572468
--echo # End of 10.5 tests

sql/sql_sort.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ class Sort_param {
545545
{
546546
memset(reinterpret_cast<void*>(this), 0, sizeof(*this));
547547
tmp_buffer.set_thread_specific();
548+
/*
549+
Fix memset() clearing the charset.
550+
TODO: The constructor should be eventually rewritten not to use memset().
551+
*/
552+
tmp_buffer.set_charset(&my_charset_bin);
548553
}
549554
void init_for_filesort(uint sortlen, TABLE *table,
550555
ha_rows maxrows, bool sort_positions);

0 commit comments

Comments
 (0)