wb_wc and wc_mb now checks length inside
This commit is contained in:
parent
ecb55f4307
commit
e7660c64d7
@ -2014,9 +2014,8 @@ String *Item_func_conv_charset::val_str(String *str)
|
|||||||
d0=d=(unsigned char*)str->ptr();
|
d0=d=(unsigned char*)str->ptr();
|
||||||
de=d+dmaxlen;
|
de=d+dmaxlen;
|
||||||
|
|
||||||
while (s < se && d < de)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
||||||
cnvres=from->mb_wc(from,&wc,s,se);
|
cnvres=from->mb_wc(from,&wc,s,se);
|
||||||
if (cnvres>0)
|
if (cnvres>0)
|
||||||
{
|
{
|
||||||
@ -2089,8 +2088,8 @@ String *Item_func_conv_charset3::val_str(String *str)
|
|||||||
d0=d=(unsigned char*)str->ptr();
|
d0=d=(unsigned char*)str->ptr();
|
||||||
de=d+dmaxlen;
|
de=d+dmaxlen;
|
||||||
|
|
||||||
while (s < se && d < de){
|
while (1)
|
||||||
|
{
|
||||||
cnvres=from_charset->mb_wc(from_charset,&wc,s,se);
|
cnvres=from_charset->mb_wc(from_charset,&wc,s,se);
|
||||||
if (cnvres>0)
|
if (cnvres>0)
|
||||||
{
|
{
|
||||||
|
@ -706,7 +706,7 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
|
|||||||
char *to_start= to;
|
char *to_start= to;
|
||||||
uchar *to_end= (uchar*) to+to_length;
|
uchar *to_end= (uchar*) to+to_length;
|
||||||
|
|
||||||
while ((uchar*) from < from_end)
|
while (1)
|
||||||
{
|
{
|
||||||
if ((cnvres=from_cs->mb_wc(from_cs, &wc, (uchar*) from, from_end)) > 0)
|
if ((cnvres=from_cs->mb_wc(from_cs, &wc, (uchar*) from, from_end)) > 0)
|
||||||
from+= cnvres;
|
from+= cnvres;
|
||||||
|
@ -6175,6 +6175,9 @@ my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
|
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if(wc<0x80)
|
if(wc<0x80)
|
||||||
{
|
{
|
||||||
s[0]=wc;
|
s[0]=wc;
|
||||||
@ -6200,6 +6203,9 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
|
|
||||||
int hi=s[0];
|
int hi=s[0];
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
if(hi<0x80)
|
if(hi<0x80)
|
||||||
{
|
{
|
||||||
pwc[0]=hi;
|
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 *str,
|
||||||
const unsigned char *end __attribute__((unused)))
|
const unsigned char *end __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
if (str >= end)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
*wc=str[0];
|
*wc=str[0];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -105,6 +108,9 @@ static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
unsigned char *s,
|
unsigned char *s,
|
||||||
unsigned char *e __attribute__((unused)))
|
unsigned char *e __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc < 256)
|
if (wc < 256)
|
||||||
{
|
{
|
||||||
s[0]= (char) wc;
|
s[0]= (char) wc;
|
||||||
|
@ -8593,6 +8593,9 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc<0x80)
|
if (wc<0x80)
|
||||||
{
|
{
|
||||||
s[0]=wc;
|
s[0]=wc;
|
||||||
@ -8618,6 +8621,9 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
|
|
||||||
int hi=s[0];
|
int hi=s[0];
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
if (hi<0x80)
|
if (hi<0x80)
|
||||||
{
|
{
|
||||||
pwc[0]=hi;
|
pwc[0]=hi;
|
||||||
|
@ -5643,6 +5643,9 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc<0x80)
|
if (wc<0x80)
|
||||||
{
|
{
|
||||||
s[0]=wc;
|
s[0]=wc;
|
||||||
@ -5668,6 +5671,9 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
|
|
||||||
hi=s[0];
|
hi=s[0];
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
if(hi<0x80)
|
if(hi<0x80)
|
||||||
{
|
{
|
||||||
pwc[0]=hi;
|
pwc[0]=hi;
|
||||||
|
@ -9829,6 +9829,9 @@ my_wc_mb_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc<0x80)
|
if (wc<0x80)
|
||||||
{
|
{
|
||||||
s[0]=wc;
|
s[0]=wc;
|
||||||
@ -9852,6 +9855,9 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int hi;
|
int hi;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
hi=s[0];
|
hi=s[0];
|
||||||
|
|
||||||
if (hi<0x80)
|
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 *str,
|
||||||
const unsigned char *end __attribute__((unused)))
|
const unsigned char *end __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
if (str >= end)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
*wc=cs->tab_to_uni[*str];
|
*wc=cs->tab_to_uni[*str];
|
||||||
return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
|
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;
|
MY_UNI_IDX *idx;
|
||||||
|
|
||||||
|
if (str >= end)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
for (idx=cs->tab_from_uni; idx->tab ; idx++)
|
for (idx=cs->tab_from_uni; idx->tab ; idx++)
|
||||||
{
|
{
|
||||||
if (idx->from <= wc && idx->to >= wc)
|
if (idx->from <= wc && idx->to >= wc)
|
||||||
|
@ -4420,6 +4420,9 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if(wc<0x80)
|
if(wc<0x80)
|
||||||
{
|
{
|
||||||
s[0]=wc;
|
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){
|
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||||
int hi=s[0];
|
int hi=s[0];
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
if(hi<0x80)
|
if(hi<0x80)
|
||||||
{
|
{
|
||||||
pwc[0]=hi;
|
pwc[0]=hi;
|
||||||
|
@ -8351,6 +8351,9 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
|
|||||||
unsigned char c1;
|
unsigned char c1;
|
||||||
int ret,jp;
|
int ret,jp;
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc<0x80)
|
if (wc<0x80)
|
||||||
{
|
{
|
||||||
if (s>e)
|
if (s>e)
|
||||||
|
@ -1586,6 +1586,9 @@ static int my_utf8_uni (CHARSET_INFO *cs __attribute__((unused)) ,
|
|||||||
{
|
{
|
||||||
unsigned char c = s[0];
|
unsigned char c = s[0];
|
||||||
|
|
||||||
|
if (s >= e)
|
||||||
|
return MY_CS_TOOFEW(0);
|
||||||
|
|
||||||
if (c < 0x80)
|
if (c < 0x80)
|
||||||
{
|
{
|
||||||
*pwc = c;
|
*pwc = c;
|
||||||
@ -1688,6 +1691,9 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
|
|||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
if (r >= e)
|
||||||
|
return MY_CS_TOOSMALL;
|
||||||
|
|
||||||
if (wc < 0x80)
|
if (wc < 0x80)
|
||||||
count = 1;
|
count = 1;
|
||||||
else if (wc < 0x800)
|
else if (wc < 0x800)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user