From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7BCD781C84 for ; Wed, 7 Dec 2016 16:54:49 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 07 Dec 2016 16:54:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,316,1477983600"; d="scan'208";a="1096160366" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.44]) by fmsmga002.fm.intel.com with ESMTP; 07 Dec 2016 16:54:47 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Zhang Lubo , Wu Jiaxin Date: Thu, 8 Dec 2016 08:54:45 +0800 Message-Id: <1481158485-25936-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [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: Thu, 08 Dec 2016 00:54:49 -0000 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 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) == 0xC0); + if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) { + Status = EFI_UNSUPPORTED; + goto ON_EXIT; + } // // Get Answer section. // AnswerSection = (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 != NULL && AnswerSection->DataLength == 4); + ASSERT (Dns4TokenEntry != NULL); + + if (AnswerSection->DataLength != 4) { + Status = EFI_ABORTED; + goto ON_EXIT; + } HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList; AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS)); @@ -1460,11 +1468,16 @@ ParseDnsResponse ( break; case DNS_TYPE_AAAA: // // This is address entry, get Data. // - ASSERT (Dns6TokenEntry != NULL && AnswerSection->DataLength == 16); + ASSERT (Dns6TokenEntry != NULL); + + if (AnswerSection->DataLength != 16) { + Status = EFI_ABORTED; + goto ON_EXIT; + } HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList; AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS)); -- 1.9.5.msysgit.1