Fix length check for valid UCS2 starting with 0xff

This commit is contained in:
Denis Kenzior 2009-07-07 13:49:32 -05:00
parent 35f7c4b068
commit 5f04cb1c3e
1 changed files with 8 additions and 1 deletions

View File

@ -720,8 +720,15 @@ char *sim_string_to_utf8(const unsigned char *buffer, int length)
switch (buffer[0]) {
case 0x80:
if (((length - 1) % 2) == 1) {
if (buffer[length - 1] != 0xff)
return NULL;
length = length - 1;
}
for (i = 1; i < length; i += 2)
if (buffer[i] == 0xff)
if (buffer[i] == 0xff && buffer[i + 1] == 0xff)
break;
return g_convert(buffer + 1, i - 1,