mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for bug #31069: crash in 'sounds like'
and for bug #31070: crash during conversion of charsets Problem: passing a 0 byte length string to some my_mb_wc_XXX() functions leads to server crash due to improper argument check. Fix: properly check arguments passed to my_mb_wc_XXX() functions.
This commit is contained in:

parent
e78513165c
commit
bc9b4834e1
@ -51,6 +51,15 @@ SELECT c1 as want1result from t1 where c1 like 'locatio%';
|
||||
SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #31070: crash during conversion of charsets
|
||||
#
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
select a sounds like a from t1;
|
||||
drop table t1;
|
||||
|
||||
DROP DATABASE d1;
|
||||
# Restore settings
|
||||
USE test;
|
||||
|
@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
cast(a as char(1))
|
||||
|
||||
|
||||
select a sounds like a from t1;
|
||||
a sounds like a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
|
@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
cast(a as char(1))
|
||||
|
||||
|
||||
select a sounds like a from t1;
|
||||
a sounds like a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
|
@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
cast(a as char(1))
|
||||
|
||||
|
||||
select a sounds like a from t1;
|
||||
a sounds like a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
|
@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
cast(a as char(1))
|
||||
|
||||
|
||||
select a sounds like a from t1;
|
||||
a sounds like a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
|
@ -2371,6 +2371,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%';
|
||||
want1result
|
||||
location
|
||||
DROP TABLE t1;
|
||||
create table t1 (a set('a') not null);
|
||||
insert into t1 values (),();
|
||||
select cast(a as char(1)) from t1;
|
||||
cast(a as char(1))
|
||||
|
||||
|
||||
select a sounds like a from t1;
|
||||
a sounds like a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
DROP DATABASE d1;
|
||||
USE test;
|
||||
SET character_set_server= @safe_character_set_server;
|
||||
|
@ -6256,12 +6256,12 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc,const uchar *s,const uchar *e)
|
||||
{
|
||||
|
||||
int hi=s[0];
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (hi<0x80)
|
||||
if ((hi= s[0]) < 0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
return 1;
|
||||
|
@ -5352,12 +5352,12 @@ my_wc_mb_cp932(CHARSET_INFO *cs __attribute__((unused)),
|
||||
static int
|
||||
my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||
int hi=s[0];
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (hi < 0x80)
|
||||
if ((hi= s[0]) < 0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
return 1;
|
||||
|
@ -8614,12 +8614,12 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e)
|
||||
{
|
||||
|
||||
int hi=s[0];
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (hi<0x80)
|
||||
if ((hi= s[0]) < 0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
return 1;
|
||||
|
@ -5665,12 +5665,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||
int hi;
|
||||
|
||||
hi=(int) s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (hi<0x80)
|
||||
if ((hi= s[0]) < 0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
return 1;
|
||||
|
@ -4512,12 +4512,12 @@ mb:
|
||||
static int
|
||||
my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||
int hi=s[0];
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (hi < 0x80)
|
||||
if ((hi= s[0]) < 0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user