MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation

This commit is contained in:
Alexander Barkov 2022-05-12 10:55:18 +04:00
parent 404984980f
commit b9adaeb491
3 changed files with 45 additions and 1 deletions

View file

@ -133,3 +133,22 @@ a c
DROP TABLE t1;
SET NAMES utf8;
# End of 10.5 tests
#
# Start of 10.9 tests
#
#
# MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation
#
SET SESSION collation_server=filename;
CREATE DATABASE db1;
USE db1;
CREATE TABLE t (c CHAR BINARY);
ERROR HY000: Unknown collation: 'filename_bin'
DROP DATABASE db1;
USE test;
SET NAMES latin1;
CREATE TABLE t1 (c CHAR BINARY) CHARACTER SET filename;
ERROR HY000: Unknown collation: 'filename_bin'
#
# End of 10.9 tests
#

View file

@ -139,3 +139,27 @@ SET NAMES utf8;
--enable_ps_protocol
--echo # End of 10.5 tests
--echo #
--echo # Start of 10.9 tests
--echo #
--echo #
--echo # MDEV-28481 SIGSEGV in Lex_charset_collation_st::find_bin_collation
--echo #
SET SESSION collation_server=filename;
CREATE DATABASE db1;
USE db1;
--error ER_UNKNOWN_COLLATION
CREATE TABLE t (c CHAR BINARY);
DROP DATABASE db1;
USE test;
SET NAMES latin1;
--error ER_UNKNOWN_COLLATION
CREATE TABLE t1 (c CHAR BINARY) CHARACTER SET filename;
--echo #
--echo # End of 10.9 tests
--echo #

View file

@ -41,10 +41,11 @@ CHARSET_INFO *Lex_charset_collation_st::find_bin_collation(CHARSET_INFO *cs)
return cs;
// CREATE TABLE t1 (a CHAR(10) BINARY) CHARACTER SET utf8mb4;
const LEX_CSTRING &cs_name= cs->cs_name;
if (!(cs= get_charset_by_csname(cs->cs_name.str, MY_CS_BINSORT, MYF(0))))
{
char tmp[65];
strxnmov(tmp, sizeof(tmp)-1, cs->cs_name.str, "_bin", NULL);
strxnmov(tmp, sizeof(tmp)-1, cs_name.str, "_bin", NULL);
my_error(ER_UNKNOWN_COLLATION, MYF(0), tmp);
}
return cs;