From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id 574651A1E05 for ; Fri, 19 Aug 2016 00:56:00 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 19 Aug 2016 00:55:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,544,1464678000"; d="scan'208";a="1017198275" Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.11]) by orsmga001.jf.intel.com with ESMTP; 19 Aug 2016 00:55:39 -0700 From: Zhang Lubo To: edk2-devel@lists.01.org Cc: Fu Siyuan , Ye Ting , Wu Jiaxin , Hegde Nagaraj P Date: Fri, 19 Aug 2016 15:53:03 +0800 Message-Id: <1471593183-7776-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] MdeModulePkg:Fix bug in function 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, 19 Aug 2016 07:56:00 -0000 If a FQDN contains 3 dots '.' like "a.b.c.com", the AsciiStrToIp4 will return success as the HostName has a valid IP address. So we need to check if it is a decimal character before using AsciiStrDecimalToUintn. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Cc: Hegde Nagaraj P --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index ef19439..f4376e9 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2724,10 +2724,13 @@ NetLibAsciiStrToIp4 ( for (Index = 0; Index < 4; Index++) { TempStr = Ip4Str; while ((*Ip4Str != '\0') && (*Ip4Str != '.')) { + if (!NET_IS_DIGIT(*Ip4Str)) { + return EFI_INVALID_PARAMETER; + } Ip4Str++; } // // The IPv4 address is X.X.X.X -- 1.9.5.msysgit.1