Skip to content

Commit

Permalink
MdeModulePkg/Bus/Usb/UsbNetwork: Check array index range before access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
makubacki authored and mergify[bot] committed Feb 26, 2024
1 parent 68238d4 commit 1f161a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1f161a7

Please sign in to comment.