From: Jiaxin Wu <jiaxin.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>,
Subramanian Sriram <sriram-s@hpe.com>,
Zhang Lubo <lubo.zhang@intel.com>, Ye Ting <ting.ye@intel.com>,
Fu Siyuan <siyuan.fu@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch 2/2] NetworkPkg: Fix potential ASSERT if NetIp4IsUnicast is called
Date: Tue, 21 Mar 2017 11:43:10 +0800 [thread overview]
Message-ID: <1490067790-68936-3-git-send-email-jiaxin.wu@intel.com> (raw)
In-Reply-To: <1490067790-68936-1-git-send-email-jiaxin.wu@intel.com>
Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Cc: Subramanian Sriram <sriram-s@hpe.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
NetworkPkg/DnsDxe/DnsProtocol.c | 4 ++--
NetworkPkg/TcpDxe/TcpMain.c | 5 +++--
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 5 +++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c
index 6d117b2..0e7ed34 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -1,9 +1,9 @@
/** @file
Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
@@ -244,11 +244,11 @@ Dns4Configure (
Ip = NTOHL (Ip);
Netmask = NTOHL (Netmask);
if (!DnsConfigData->UseDefaultSetting &&
- ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) {
+ ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
Status = Dns4CopyConfigure (&Instance->Dns4CfgData, DnsConfigData);
diff --git a/NetworkPkg/TcpDxe/TcpMain.c b/NetworkPkg/TcpDxe/TcpMain.c
index 03942ee..fc3713e 100644
--- a/NetworkPkg/TcpDxe/TcpMain.c
+++ b/NetworkPkg/TcpDxe/TcpMain.c
@@ -1,10 +1,10 @@
/** @file
Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -157,11 +157,12 @@ Tcp4Configure (
if (!TcpConfigData->AccessPoint.UseDefaultAddress) {
CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
- if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask))) {
+ if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||
+ (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {
return EFI_INVALID_PARAMETER;
}
}
Option = TcpConfigData->ControlOption;
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 36477e9..ab9e494 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -1083,11 +1083,12 @@ EfiPxeBcUdpWrite (
DoNotFragment = FALSE;
} else {
DoNotFragment = TRUE;
}
- if (!Mode->UsingIpv6 && GatewayIp != NULL && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) {
+ if (!Mode->UsingIpv6 && GatewayIp != NULL && Mode->SubnetMask.Addr[0] != 0 &&
+ !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) {
//
// Gateway is provided but it's not a unicast IPv4 address, while it will be ignored for IPv6.
//
return EFI_INVALID_PARAMETER;
}
@@ -2014,11 +2015,11 @@ EfiPxeBcSetStationIP (
}
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])))) {
+ (NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
return EFI_INVALID_PARAMETER;
}
}
if (!Mode->Started) {
--
1.9.5.msysgit.1
next prev parent reply other threads:[~2017-03-21 3:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 3:43 [Patch 0/2] Fix potential ASSERT if NetIp4IsUnicast is called Jiaxin Wu
2017-03-21 3:43 ` [Patch 1/2] MdeModulePkg/Network: " Jiaxin Wu
2017-03-21 3:43 ` Jiaxin Wu [this message]
2017-03-21 4:58 ` [Patch 0/2] " Hegde, Nagaraj P
2017-03-21 7:10 ` Ye, Ting
2017-03-21 7:25 ` Subramanian, Sriram
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=1490067790-68936-3-git-send-email-jiaxin.wu@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