From 0e5e7996c9366fd6f710963c6a414003fd5a95ec Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Thu, 8 Dec 2016 08:52:41 +0800 Subject: 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 Reviewed-by: Ye Ting Reviewed-by: Zhang Lubo --- NetworkPkg/DnsDxe/DnsImpl.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'NetworkPkg') diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c index 74deaa4330..794df1d728 100644 --- a/NetworkPkg/DnsDxe/DnsImpl.c +++ b/NetworkPkg/DnsDxe/DnsImpl.c @@ -1330,9 +1330,12 @@ ParseDnsResponse ( // 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. @@ -1408,7 +1411,12 @@ ParseDnsResponse ( // // 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); @@ -1462,7 +1470,12 @@ ParseDnsResponse ( // // 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); -- cgit v1.2.3