From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 4922481E6C for ; Thu, 17 Nov 2016 23:40:13 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP; 17 Nov 2016 23:40:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,655,1473145200"; d="scan'208";a="192886917" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.191]) by fmsmga004.fm.intel.com with ESMTP; 17 Nov 2016 23:40:16 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Fu Siyuan , Ye Ting , Zhang Lubo Date: Fri, 18 Nov 2016 15:40:15 +0800 Message-Id: <1479454815-140484-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] MdeModulePkg/DxeNetLib: Allow the IPv4/prefix case when AsciiStrToIp4 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: Fri, 18 Nov 2016 07:40:13 -0000 This patch is used to allow the IPv4 with prefix case. Cc: Fu Siyuan Cc: Ye Ting Cc: Zhang Lubo Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 04d8345..0804052 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2722,13 +2722,21 @@ NetLibAsciiStrToIp4 ( for (Index = 0; Index < 4; Index++) { TempStr = Ip4Str; while ((*Ip4Str != '\0') && (*Ip4Str != '.')) { - if (!NET_IS_DIGIT (*Ip4Str)) { + if (Index != 3 && !NET_IS_DIGIT (*Ip4Str)) { return EFI_INVALID_PARAMETER; } + + // + // Allow the IPv4 with prefix case, e.g. 192.168.10.10/24 + // + if (Index == 3 && !NET_IS_DIGIT (*Ip4Str) && *Ip4Str != '/') { + return EFI_INVALID_PARAMETER; + } + Ip4Str++; } // // The IPv4 address is X.X.X.X -- 1.9.5.msysgit.1