mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
wb_wc and wc_mb now checks length inside
This commit is contained in:
@ -6175,6 +6175,9 @@ my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if(wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -6200,6 +6203,9 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -96,6 +96,9 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)),
|
||||
const unsigned char *str,
|
||||
const unsigned char *end __attribute__((unused)))
|
||||
{
|
||||
if (str >= end)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
*wc=str[0];
|
||||
return 1;
|
||||
}
|
||||
@ -105,6 +108,9 @@ static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
|
||||
unsigned char *s,
|
||||
unsigned char *e __attribute__((unused)))
|
||||
{
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc < 256)
|
||||
{
|
||||
s[0]= (char) wc;
|
||||
|
@ -8593,6 +8593,9 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -8618,6 +8621,9 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if (hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -5643,6 +5643,9 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -5668,6 +5671,9 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -9829,6 +9829,9 @@ my_wc_mb_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -9852,6 +9855,9 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
hi=s[0];
|
||||
|
||||
if (hi<0x80)
|
||||
|
@ -106,6 +106,9 @@ int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc,
|
||||
const unsigned char *str,
|
||||
const unsigned char *end __attribute__((unused)))
|
||||
{
|
||||
if (str >= end)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
*wc=cs->tab_to_uni[*str];
|
||||
return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
|
||||
}
|
||||
@ -116,6 +119,9 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
|
||||
{
|
||||
MY_UNI_IDX *idx;
|
||||
|
||||
if (str >= end)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
for (idx=cs->tab_from_uni; idx->tab ; idx++)
|
||||
{
|
||||
if (idx->from <= wc && idx->to >= wc)
|
||||
|
@ -4420,6 +4420,9 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if(wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -4442,6 +4445,9 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -8350,6 +8350,9 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
|
||||
unsigned char buf[2];
|
||||
unsigned char c1;
|
||||
int ret,jp;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
|
@ -1586,6 +1586,9 @@ static int my_utf8_uni (CHARSET_INFO *cs __attribute__((unused)) ,
|
||||
{
|
||||
unsigned char c = s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if (c < 0x80)
|
||||
{
|
||||
*pwc = c;
|
||||
@ -1688,6 +1691,9 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
|
||||
{
|
||||
int count;
|
||||
|
||||
if (r >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc < 0x80)
|
||||
count = 1;
|
||||
else if (wc < 0x800)
|
||||
|
Reference in New Issue
Block a user