From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 D3DF6823C9 for ; Thu, 22 Dec 2016 22:36:08 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 22 Dec 2016 22:36:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,392,1477983600"; d="scan'208";a="21975332" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 22 Dec 2016 22:36:08 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Dec 2016 22:36:08 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Dec 2016 22:36:07 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Fri, 23 Dec 2016 14:36:05 +0800 From: "Zhang, Lubo" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Thread-Index: AQHSUO2xZuK/bd0xH0m36GQ79/4WOqEVJz9A Date: Fri, 23 Dec 2016 06:36:05 +0000 Message-ID: <7619447B08B8F74DA4FF2A813B79803B39AED3A2@shsmsx102.ccr.corp.intel.com> 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: 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 06:36:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Looks good to me. Reviewed-by: Zhang Lubo > -----Original Message----- > From: Wu, Jiaxin > 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 >=20 > Fix the DnsDxe assert issue when the incorrect answer message received. >=20 > 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(-) >=20 > diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c > index 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_ADDRE= SS)); >=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_ADDRE= SS)); >=20 > -- > 1.9.5.msysgit.1