From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 0069A82416 for ; Thu, 22 Dec 2016 23:22:08 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 22 Dec 2016 23:22:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,392,1477983600"; d="scan'208";a="915455034" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 22 Dec 2016 23:22:08 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Dec 2016 23:22:08 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Dec 2016 23:22:08 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Fri, 23 Dec 2016 15:22:06 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Zhang, Lubo" Thread-Topic: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Thread-Index: AQHSUO2x3BJ4BBa3qUS+QLh5h34lWKEVOJIQ Date: Fri, 23 Dec 2016 07:22:06 +0000 Message-ID: References: <1481158485-25936-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1481158485-25936-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] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe 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, 23 Dec 2016 07:22:09 -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: Thursday, December 08, 2016 8:55 AM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Zhang, = Lubo ; Wu, Jiaxin Subject: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Fix the DnsDxe assert issue when the incorrect answer message received. Cc: Ye Ting Cc: Fu Siyuan Cc: Zhang Lubo Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/DnsDxe/DnsImpl.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c inde= x 74deaa4..794df1d 100644 --- a/NetworkPkg/DnsDxe/DnsImpl.c +++ b/NetworkPkg/DnsDxe/DnsImpl.c @@ -1328,13 +1328,16 @@ ParseDnsResponse ( // // Processing AnswerSection. // while (AnswerSectionNum < DnsHeader->AnswersNum) { // - // Answer name should be PTR. + // Answer name should be PTR, else EFI_UNSUPPORTED returned. // - ASSERT ((*(UINT8 *) AnswerName & 0xC0) =3D=3D 0xC0); + if ((*(UINT8 *) AnswerName & 0xC0) !=3D 0xC0) { + Status =3D EFI_UNSUPPORTED; + goto ON_EXIT; + } =20 // // Get Answer section. // AnswerSection =3D (DNS_ANSWER_SECTION *) (AnswerName + sizeof (UINT16)= ); @@ -1406,11 +1409,16 @@ ParseDnsResponse ( switch (AnswerSection->Type) { case DNS_TYPE_A: // // This is address entry, get Data. // - ASSERT (Dns4TokenEntry !=3D NULL && AnswerSection->DataLength =3D= =3D 4); + ASSERT (Dns4TokenEntry !=3D NULL); + + if (AnswerSection->DataLength !=3D 4) { + Status =3D EFI_ABORTED; + goto ON_EXIT; + } =20 HostAddr4 =3D Dns4TokenEntry->Token->RspData.H2AData->IpList; AnswerData =3D (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS= )); =20 @@ -1460,11 +1468,16 @@ ParseDnsResponse ( break; case DNS_TYPE_AAAA: // // This is address entry, get Data. // - ASSERT (Dns6TokenEntry !=3D NULL && AnswerSection->DataLength =3D= =3D 16); + ASSERT (Dns6TokenEntry !=3D NULL); + + if (AnswerSection->DataLength !=3D 16) { + Status =3D EFI_ABORTED; + goto ON_EXIT; + } =20 HostAddr6 =3D Dns6TokenEntry->Token->RspData.H2AData->IpList; AnswerData =3D (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS= )); =20 -- 1.9.5.msysgit.1