public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Fu Siyuan <siyuan.fu@intel.com>
To: edk2-devel@lists.01.org
Cc: Ye Ting <ting.ye@intel.com>, Zhang Lubo <lubo.zhang@intel.com>,
	Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch 2/2] NetworkPkg: Check for NULL pointer before dereference it.
Date: Mon, 31 Oct 2016 10:23:01 +0800	[thread overview]
Message-ID: <1477880581-12760-3-git-send-email-siyuan.fu@intel.com> (raw)
In-Reply-To: <1477880581-12760-1-git-send-email-siyuan.fu@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 52095c5..0552174 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -2013,10 +2013,14 @@ EfiPxeBcSetStationIP (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (!Mode->UsingIpv6 && NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) {
-    return EFI_INVALID_PARAMETER;
+  if (!Mode->UsingIpv6 && NewStationIp != NULL) {
+    if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) || 
+        IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
+        (NewSubnetMask != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
+      return EFI_INVALID_PARAMETER;
+    }
   }
-
+  
   if (!Mode->Started) {
     return EFI_NOT_STARTED;
   }
-- 
2.7.4.windows.1



  parent reply	other threads:[~2016-10-31  2:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31  2:22 [Patch 0/2] Check for NULL pointer before dereference Fu Siyuan
2016-10-31  2:23 ` [Patch 1/2] MdeModulePkg: Check for NULL pointer before dereference it Fu Siyuan
2016-10-31  7:22   ` Wu, Jiaxin
2016-10-31  7:29     ` Fu, Siyuan
2016-10-31  7:35       ` Ye, Ting
2016-10-31  2:23 ` Fu Siyuan [this message]
2016-10-31  7:22   ` [Patch 2/2] NetworkPkg: " Wu, Jiaxin
2016-10-31  7:35     ` Ye, Ting

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477880581-12760-3-git-send-email-siyuan.fu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox