From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 32AC7222CF1A5 for ; Wed, 10 Jan 2018 21:34:33 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 21:39:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,343,1511856000"; d="scan'208";a="18333113" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 10 Jan 2018 21:39:45 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 Jan 2018 21:39:45 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 Jan 2018 21:39:44 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 11 Jan 2018 13:39:43 +0800 From: "Wu, Hao A" To: "Wang, Fan" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wu, Jiaxin" Thread-Topic: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). Thread-Index: AQHTioVbA7TXRSG9BEubsM1UVdWtq6NuKAMw Date: Thu, 11 Jan 2018 05:39:43 +0000 Message-ID: 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: 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/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 05:34:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan; Wu, Jiaxin; Wu, 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