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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F74281EE5 for ; Thu, 24 Nov 2016 23:20:53 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 24 Nov 2016 23:20:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,693,1473145200"; d="scan'208";a="1063977470" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 24 Nov 2016 23:20:52 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Nov 2016 23:20:52 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Nov 2016 23:20:52 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.96]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.239]) with mapi id 14.03.0248.002; Fri, 25 Nov 2016 15:20:50 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Zhang, Lubo" , "Fu, Siyuan" Thread-Topic: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case Thread-Index: AQHSRuNrHGGySoCGWUeZAq5WwgkGzKDpSwVA Date: Fri, 25 Nov 2016 07:20:49 +0000 Message-ID: References: <1480054550-201956-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1480054550-201956-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case 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, 25 Nov 2016 07:20:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Friday, November 25, 2016 2:16 PM To: edk2-devel@lists.01.org Cc: Zhang, Lubo ; Fu, Siyuan ; Y= e, Ting Subject: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case Handle an invalid IPv6 address in NetLibAsciiStrToIp6(), like '2000:aaaa::1= com'. Cc: Zhang Lubo Cc: Fu Siyuan Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- MdeModulePkg/Include/Library/NetLib.h | 1 + MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/MdeModulePkg/Include/Library/NetLib.h b/MdeModulePkg/Include/L= ibrary/NetLib.h index 26709af..09ead09 100644 --- a/MdeModulePkg/Include/Library/NetLib.h +++ b/MdeModulePkg/Include/Library/NetLib.h @@ -521,10 +521,11 @@ extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM]; =20 =20 extern EFI_IPv4_ADDRESS mZeroIp4Addr; =20 #define NET_IS_DIGIT(Ch) (('0' <=3D (Ch)) && ((Ch) <=3D '9')) +#define NET_IS_HEX(Ch) ((('0' <=3D (Ch)) && ((Ch) <=3D '9')) = || (('A' <=3D (Ch)) && ((Ch) <=3D 'F')) || (('a' <=3D (Ch)) && ((Ch) <=3D '= f'))) #define NET_ROUNDUP(size, unit) (((size) + (unit) - 1) & (~((unit) - 1= ))) #define NET_IS_LOWER_CASE_CHAR(Ch) (('a' <=3D (Ch)) && ((Ch) <=3D 'z')) = #define NET_IS_UPPER_CASE_CHAR(Ch) (('A' <=3D (Ch)) && ((Ch) <=3D 'Z')) =20 #define TICKS_PER_MS 10000U diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Libr= ary/DxeNetLib/DxeNetLib.c index 0804052..0a7117c 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2830,10 +2830,21 @@ NetLibAsciiStrToIp6 ( =20 for (Index =3D 0; Index < 15; Index =3D (UINT8) (Index + 2)) { TempStr =3D Ip6Str; =20 while ((*Ip6Str !=3D '\0') && (*Ip6Str !=3D ':')) { + if (Index !=3D 14 && !NET_IS_HEX (*Ip6Str)) { + return EFI_INVALID_PARAMETER; + } + =20 + // + // Allow the IPv6 with prefix case, e.g. 2000:aaaa::10/24=20 + // + if (Index =3D=3D 14 && !NET_IS_HEX (*Ip6Str) && *Ip6Str !=3D '/') { + return EFI_INVALID_PARAMETER; + } + =20 Ip6Str++; } =20 if ((*Ip6Str =3D=3D '\0') && (Index !=3D 14)) { return EFI_INVALID_PARAMETER; -- 1.9.5.msysgit.1