mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
unicode: Explicitly set INT_MAX for unlimited utf8_size
-1 could be supplied unintentionally from user code when utf8_size is computable value Fixup for004304dc
and1f548f74
Change-Id: I93008ea289bdb134f051975c25b0db9d0e64b823
This commit is contained in:
parent
44e97b9ef6
commit
059df3782f
1 changed files with 3 additions and 9 deletions
|
@ -280,15 +280,12 @@ unsigned char* utf8encode(unsigned long ucs, unsigned char *utf8)
|
|||
|
||||
unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8, int cp, int count)
|
||||
{
|
||||
return iso_decode_ex(iso, utf8, cp, count, -1);
|
||||
return iso_decode_ex(iso, utf8, cp, count, INT_MAX);
|
||||
}
|
||||
|
||||
/* Recode an iso encoded string to UTF-8 */
|
||||
unsigned char* iso_decode_ex(const unsigned char *iso, unsigned char *utf8, int cp, int count, int utf8_size)
|
||||
{
|
||||
if (utf8_size == -1)
|
||||
utf8_size = INT_MAX;
|
||||
|
||||
uint16_t *table = NULL;
|
||||
|
||||
cp_lock_enter();
|
||||
|
@ -423,9 +420,6 @@ unsigned char* iso_decode_ex(const unsigned char *iso, unsigned char *utf8, int
|
|||
unsigned char* utf16decode(const unsigned char *utf16, unsigned char *utf8,
|
||||
int count, int utf8_size, bool le)
|
||||
{
|
||||
if (utf8_size == -1)
|
||||
utf8_size = INT_MAX;
|
||||
|
||||
// little-endian flag is used as significant byte index
|
||||
if (le)
|
||||
le = 1;
|
||||
|
@ -453,13 +447,13 @@ unsigned char* utf16decode(const unsigned char *utf16, unsigned char *utf8,
|
|||
unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8,
|
||||
int count)
|
||||
{
|
||||
return utf16decode(utf16, utf8, count, -1, true);
|
||||
return utf16decode(utf16, utf8, count, INT_MAX, true);
|
||||
}
|
||||
|
||||
unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8,
|
||||
int count)
|
||||
{
|
||||
return utf16decode(utf16, utf8, count, -1, false);
|
||||
return utf16decode(utf16, utf8, count, INT_MAX, false);
|
||||
}
|
||||
|
||||
bool utf16_has_bom(const unsigned char *utf16, bool *le)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue