1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug #51876: crash/memory underrun when loading data with ucs2

and reverse() function
      
3 problems fixed : 
1. The reported problem : caused by incorrect parsing of 
the file as ucs data resulting in wrong length of the parsed
string. Fixed by truncating the invalid trailing bytes 
(non-complete multibyte characters) when reading from the file
2. LOAD DATA when reading from a proper UCS2 file wasn't 
recognizing the new line characters. Fixed by first looking 
if a byte is a new line (or any other special) character before
reading it as a part of a multibyte character.
3. When using user variables to hold the column data in LOAD
DATA the character set of the user variable was set incorrectly
to the database charset. Fixed by setting it to the charset
specified by LOAD DATA (if any).
This commit is contained in:
Georgi Kodinov
2010-07-14 14:54:51 +03:00
parent 678640019d
commit dbb643d64e
4 changed files with 98 additions and 24 deletions

View File

@ -1208,29 +1208,6 @@ int READ_INFO::read_field()
while ( to < end_of_buff)
{
chr = GET;
#ifdef USE_MB
if ((my_mbcharlen(read_charset, chr) > 1) &&
to+my_mbcharlen(read_charset, chr) <= end_of_buff)
{
uchar* p = (uchar*)to;
*to++ = chr;
int ml = my_mbcharlen(read_charset, chr);
int i;
for (i=1; i<ml; i++) {
chr = GET;
if (chr == my_b_EOF)
goto found_eof;
*to++ = chr;
}
if (my_ismbchar(read_charset,
(const char *)p,
(const char *)to))
continue;
for (i=0; i<ml; i++)
PUSH((uchar) *--to);
chr = GET;
}
#endif
if (chr == my_b_EOF)
goto found_eof;
if (chr == escape_char)
@ -1314,6 +1291,39 @@ int READ_INFO::read_field()
return 0;
}
}
#ifdef USE_MB
if (my_mbcharlen(read_charset, chr) > 1 &&
to + my_mbcharlen(read_charset, chr) <= end_of_buff)
{
uchar* p= (uchar*) to;
int ml, i;
*to++ = chr;
ml= my_mbcharlen(read_charset, chr);
for (i= 1; i < ml; i++)
{
chr= GET;
if (chr == my_b_EOF)
{
/*
Need to back up the bytes already ready from illformed
multi-byte char
*/
to-= i;
goto found_eof;
}
*to++ = chr;
}
if (my_ismbchar(read_charset,
(const char *)p,
(const char *)to))
continue;
for (i= 0; i < ml; i++)
PUSH((uchar) *--to);
chr= GET;
}
#endif
*to++ = (uchar) chr;
}
/*