public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] NetworkPkg/IScsiDxe: Enhance the check for array boundary
@ 2020-04-24  9:13 Zhang, Shenglei
  2020-04-26  1:00 ` [edk2-devel] " Siyuan, Fu
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Shenglei @ 2020-04-24  9:13 UTC (permalink / raw)
  To: devel; +Cc: Maciej Rabeda, Jiaxin Wu, Siyuan Fu

Array 'TargetUrl' of size 255 may use index value(s) 255 and 256.
So enhance the boundary check to ensure the index is valid.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c  | 2 +-
 NetworkPkg/IScsiDxe/IScsiDhcp6.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 7ce9bf575012..afa8a86cd419 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -122,7 +122,7 @@ IScsiDhcpExtractRootPath (
   //
   if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) != '[')) {
     ConfigNvData->DnsMode = TRUE;
-    if (Field->Len > sizeof (ConfigNvData->TargetUrl)) {
+    if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
       return EFI_INVALID_PARAMETER;
     }
     CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
index 86a872adeccc..691650b7334f 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
@@ -161,7 +161,7 @@ IScsiDhcp6ExtractRootPath (
   // Server name is expressed as domain name, just save it.
   //
   if (ConfigNvData->DnsMode) {
-    if (Field->Len > sizeof (ConfigNvData->TargetUrl)) {
+    if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
       return EFI_INVALID_PARAMETER;
     }
     CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
-- 
2.18.0.windows.1


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

end of thread, other threads:[~2020-04-26  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24  9:13 [PATCH] NetworkPkg/IScsiDxe: Enhance the check for array boundary Zhang, Shenglei
2020-04-26  1:00 ` [edk2-devel] " Siyuan, Fu

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