diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-07-25 18:12:57 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-07-25 18:12:57 +0000 |
| commit | b40eb3d6627214a7e5a886f972022576799568ec (patch) | |
| tree | 9158eadb70ce070919a1dac0fe8ba8521002f7f8 /firmware/common | |
| parent | e0d64b95db0664bcf374dc6c52707adfac910759 (diff) | |
| download | rockbox-b40eb3d6627214a7e5a886f972022576799568ec.zip rockbox-b40eb3d6627214a7e5a886f972022576799568ec.tar.gz rockbox-b40eb3d6627214a7e5a886f972022576799568ec.tar.bz2 rockbox-b40eb3d6627214a7e5a886f972022576799568ec.tar.xz | |
Fixed unicode buffer overflow issue (metadata parser crashed with some
mp3 files).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10324 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
| -rw-r--r-- | firmware/common/unicode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c index 8378039..1dc7eed 100644 --- a/firmware/common/unicode.c +++ b/firmware/common/unicode.c @@ -170,11 +170,11 @@ unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8, /* Recode a UTF-16 string with little-endian byte ordering to UTF-8 */ unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8, - unsigned int count) + int count) { unsigned long ucs; - while (count != 0) { + while (count > 0) { /* Check for a surrogate pair */ if (utf16[1] >= 0xD8 && utf16[1] < 0xE0) { ucs = 0x10000 + ((utf16[0] << 10) | ((utf16[1] - 0xD8) << 18) @@ -193,11 +193,11 @@ unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8, /* Recode a UTF-16 string with big-endian byte ordering to UTF-8 */ unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8, - unsigned int count) + int count) { unsigned long ucs; - while (count != 0) { + while (count > 0) { if (*utf16 >= 0xD8 && *utf16 < 0xE0) { /* Check for a surrogate pair */ ucs = 0x10000 + (((utf16[0] - 0xD8) << 18) | (utf16[1] << 10) | ((utf16[2] - 0xDC) << 8) | utf16[3]); |