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.88; helo=mga01.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org 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 87CEC2220D204 for ; Wed, 10 Jan 2018 23:42:36 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 23:47:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,343,1511856000"; d="scan'208";a="194083615" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 10 Jan 2018 23:47:49 -0800 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 Jan 2018 23:47:49 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 Jan 2018 23:47:49 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 11 Jan 2018 15:47:47 +0800 From: "Wu, Jiaxin" To: "Wang, Fan" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wu, Hao A" Thread-Topic: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). Thread-Index: AQHTioVbsgbRlMJcl0mGQsCX+ESv4KNuSUOw Date: Thu, 11 Jan 2018 07:47:46 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B72741635C2FD@SHSMSX103.ccr.corp.intel.com> References: <1515638323-13024-1-git-send-email-fan.wang@intel.com> In-Reply-To: <1515638323-13024-1-git-send-email-fan.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWQ4MzVjOTQtZmY2Yi00MTEzLThkZDItMmEzM2UxMjVlYmJmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IjZub0lneER1Tm94NlI4MEZmSk85dDR4WFU2OXpSMHIyd1ZFU1wvQlVtYytJPSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). 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: Thu, 11 Jan 2018 07:42:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Fan, I think we need to update the below ASSERT if apply you patch: ASSERT ((Ip1 !=3D NULL) && (Ip2 !=3D NULL) && (PrefixLength <=3D IP6_PREFI= X_MAX)); Update To:=20 ASSERT ((Ip1 !=3D NULL) && (Ip2 !=3D NULL) && (PrefixLength < IP6_PREFIX_M= AX)); If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16: Byte =3D (UINT8) (PrefixLength / 8); So, it will conflict with your patch ASSERT: ASSERT (Byte < 16); Thanks, Jiaxin > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan ; Wu, Jiaxin ; W= u, > Hao A > Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in > NetIp6IsNetEqual(). >=20 > * The library API use array elements without any index range check, this > patch is to fix this issue to avoid null pointer reference. >=20 > Cc: Fu Siyuan > Cc: Jiaxin Wu > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index cbce28f..34e11a8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( > } >=20 > if (Bit > 0) { > Mask =3D (UINT8) (0xFF << (8 - Bit)); >=20 > + ASSERT (Byte < 16); > + if (Byte >=3D 16) { > + return FALSE; > + } > if ((Ip1->Addr[Byte] & Mask) !=3D (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } >=20 > -- > 1.9.5.msysgit.1