public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v1 1/1] MdeModulePkg/Bus/Usb/UsbNetwork: Check array index range before access
@ 2024-02-20 15:21 Michael Kubacki
  2024-02-26 17:10 ` 回复: " gaoliming via groups.io
  2024-02-27  0:52 ` Rebecca Cran
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Kubacki @ 2024-02-20 15:21 UTC (permalink / raw)
  To: devel; +Cc: Liming Gao, Ray Ni, Rebecca Cran, Richard Ho

From: Michael Kubacki <michael.kubacki@microsoft.com>

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>
---
 MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c  | 2 +-
 MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c  | 2 +-
 MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c
index 29f4508a38ce..0c1f252b85df 100644
--- a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c
+++ b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c
@@ -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;
     }
diff --git a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c
index baa2225bf8a8..ef01a6f5458c 100644
--- a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c
+++ b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c
@@ -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;
     }
diff --git a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c
index 2c0dcae4cf96..6d45a1b775ba 100644
--- a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c
+++ b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c
@@ -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;
     }
-- 
2.40.1.vfs.0.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115654): https://edk2.groups.io/g/devel/message/115654
Mute This Topic: https://groups.io/mt/104469090/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-27  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 15:21 [edk2-devel] [PATCH v1 1/1] MdeModulePkg/Bus/Usb/UsbNetwork: Check array index range before access Michael Kubacki
2024-02-26 17:10 ` 回复: " gaoliming via groups.io
2024-02-27  0:52 ` Rebecca Cran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox