lib_iconv.c:Fix possible out-of-bounds reads
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
parent
c9bc6b1ad5
commit
4ce205cf08
@ -420,6 +420,20 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb,
|
|||||||
|
|
||||||
to = extract_to(cd);
|
to = extract_to(cd);
|
||||||
from = extract_from(cd);
|
from = extract_from(cd);
|
||||||
|
if (to > sizeof(g_charmaps) - 1)
|
||||||
|
{
|
||||||
|
/* Avoid going outside the range of the array */
|
||||||
|
|
||||||
|
to = sizeof(g_charmaps) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (from > sizeof(g_charmaps) - 1)
|
||||||
|
{
|
||||||
|
/* Avoid going outside the range of the array */
|
||||||
|
|
||||||
|
from = sizeof(g_charmaps) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
map = g_charmaps + from + 1;
|
map = g_charmaps + from + 1;
|
||||||
tomap = g_charmaps + to + 1;
|
tomap = g_charmaps + to + 1;
|
||||||
type = map[0 - 1];
|
type = map[0 - 1];
|
||||||
|
Loading…
Reference in New Issue
Block a user