MdeModulePkg/Bus/Usb/UsbNetwork: Check array index range before access

Checks that an offset used to access array elements is within the
expected range before accessing the array item.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Richard Ho <richardho@ami.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki 2024-02-15 14:16:55 -05:00 committed by mergify[bot]
parent 68238d4f94
commit 1f161a7915
3 changed files with 3 additions and 3 deletions

View File

@ -769,7 +769,7 @@ ConvertFilter (
Count = sizeof (gTable)/sizeof (gTable[0]);
for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
if (gTable[Index].Src & Value) {
*CdcFilter |= gTable[Index].Dst;
}

View File

@ -855,7 +855,7 @@ ConvertFilter (
Count = sizeof (gTable)/sizeof (gTable[0]);
for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
if (gTable[Index].Src & Value) {
*CdcFilter |= gTable[Index].Dst;
}

View File

@ -803,7 +803,7 @@ ConvertFilter (
Count = sizeof (gTable)/sizeof (gTable[0]);
for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
if (gTable[Index].Src & Value) {
*CdcFilter |= gTable[Index].Dst;
}