From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 14BF181D16 for ; Sun, 30 Oct 2016 19:23:12 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 30 Oct 2016 19:23:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,572,1473145200"; d="scan'208";a="895818605" Received: from sfu5-mobl3.ccr.corp.intel.com ([10.239.192.234]) by orsmga003.jf.intel.com with ESMTP; 30 Oct 2016 19:23:11 -0700 From: Fu Siyuan To: edk2-devel@lists.01.org Cc: Ye Ting , Zhang Lubo , Wu Jiaxin Date: Mon, 31 Oct 2016 10:23:01 +0800 Message-Id: <1477880581-12760-3-git-send-email-siyuan.fu@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1477880581-12760-1-git-send-email-siyuan.fu@intel.com> References: <1477880581-12760-1-git-send-email-siyuan.fu@intel.com> Subject: [Patch 2/2] NetworkPkg: Check for NULL pointer before dereference it. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 02:23:12 -0000 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Cc: Ye Ting Cc: Zhang Lubo Cc: Wu Jiaxin --- 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