1
0
Fork 0
forked from nuttx/nuttx-update

drivers/usbhost/hid_parser.c: Fix out of range array accesses

Found by clang-check:

usbhost/hid_parser.c:278:26: warning: Assigned value is garbage or undefined
                usage[i] = usage[i + 1];
                         ^ ~~~~~~~~~~~~
usbhost/hid_parser.c:321:34: warning: Assigned value is garbage or undefined
                        usage[i] = usage[i + 1];
                                 ^ ~~~~~~~~~~~~
2 warnings generated.
This commit is contained in:
YAMAMOTO Takashi 2020-08-04 10:17:41 +09:00 committed by Xiang Xiao
parent 4f7745ae1c
commit 59ba52aee8

View file

@ -274,8 +274,8 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
{
collectionpath->usage.usage = usage[0];
for (i = 0; i < nusage; i++)
usage[i] = usage[i + 1];
for (i = 1; i < nusage; i++)
usage[i - 1] = usage[i];
nusage--;
}
@ -316,9 +316,9 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
{
newitem.attrib.usage.usage = usage[0];
for (i = 0; i < nusage; i++)
for (i = 1; i < nusage; i++)
{
usage[i] = usage[i + 1];
usage[i - 1] = usage[i];
}
nusage--;
}