From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9EDDC222EDCEB for ; Mon, 1 Jan 2018 18:39:55 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2018 18:44:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,494,1508828400"; d="scan'208";a="16108536" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by FMSMGA003.fm.intel.com with ESMTP; 01 Jan 2018 18:44:56 -0800 From: fanwang2 To: edk2-devel@lists.01.org Cc: Wang Fan , Jiaxin Wu , Ye Ting , Fu Siyuan Date: Tue, 2 Jan 2018 10:44:47 +0800 Message-Id: <1514861087-5868-1-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 02:39:56 -0000 From: Wang Fan The Dhcp4.TransmitReceive() API should be able to use at any time according to UEFI spec. While in classless addressing network, the netmask must be explicitly provided together with the station address. But if the DHCP instance haven't be configured with a valid netmask, we need compute it according to the classful addressing rule. In such case, if the user configures with class E IP address, ASSERT will happen, we need to handle this case and return error status code. Cc: Jiaxin Wu Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index aad6674..b95aede 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -1184,12 +1184,14 @@ EfiDhcp4Build ( Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance. @param[in] UdpIo The UdpIo being created. @param[in] Context Dhcp4 instance. - @retval EFI_SUCCESS UdpIo is configured successfully. - @retval other Other error occurs. + @retval EFI_SUCCESS UdpIo is configured successfully. + @retval EFI_INVALID_PARAMETER Class E IP address is not supported or other parameters + are not valid. + @retval other Other error occurs. **/ EFI_STATUS EFIAPI Dhcp4InstanceConfigUdpIo ( IN UDP_IO *UdpIo, @@ -1227,11 +1229,18 @@ Dhcp4InstanceConfigUdpIo ( // provided together with the station address. // If the DHCP instance haven't be configured with a valid netmask, we could only // compute it according to the classful addressing rule. // Class = NetGetIpClass (ClientAddr); + // + // Class E IP address is not supported here! + // ASSERT (Class < IP4_ADDR_CLASSE); + if (Class >= IP4_ADDR_CLASSE) { + return EFI_INVALID_PARAMETER; + } + SubnetMask = gIp4AllMasks[Class << 3]; } else { SubnetMask = DhcpSb->Netmask; } -- 1.9.5.msysgit.1