From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 2D44181EE3 for ; Thu, 24 Nov 2016 22:43:36 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP; 24 Nov 2016 22:43:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,693,1473145200"; d="scan'208";a="35385504" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 24 Nov 2016 22:43:35 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Nov 2016 22:43:35 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.96]) with mapi id 14.03.0248.002; Fri, 25 Nov 2016 14:43:33 +0800 From: "Fu, Siyuan" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Zhang, Lubo" , "Ye, Ting" Thread-Topic: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case Thread-Index: AQHSRuNr+FQHLAlMg0S/2Aj+jwAcUKDpQKwg Date: Fri, 25 Nov 2016 06:43:33 +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: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjAxNmYwMDktNGM3ZC00NDA3LTljNmUtNDJlYTRhMjEyZTNiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlpwZTduMGpGS1FQdGZFM0xHMmdcL2s5OUxra0NmblNNTjlOcXlqcktVNWU0PSJ9 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 06:43:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: Wu, Jiaxin > Sent: Friday, November 25, 2016 2:16 PM > To: edk2-devel@lists.01.org > Cc: Zhang, Lubo ; Fu, Siyuan ; > Ye, Ting > Subject: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case >=20 > Handle an invalid IPv6 address in NetLibAsciiStrToIp6(), > like '2000:aaaa::1com'. >=20 > 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(+) >=20 > diff --git a/MdeModulePkg/Include/Library/NetLib.h > b/MdeModulePkg/Include/Library/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/Library/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; > + } > + > + // > + // Allow the IPv6 with prefix case, e.g. 2000:aaaa::10/24 > + // > + if (Index =3D=3D 14 && !NET_IS_HEX (*Ip6Str) && *Ip6Str !=3D '/') = { > + return EFI_INVALID_PARAMETER; > + } > + > Ip6Str++; > } >=20 > if ((*Ip6Str =3D=3D '\0') && (Index !=3D 14)) { > return EFI_INVALID_PARAMETER; > -- > 1.9.5.msysgit.1