NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe

Fix the DnsDxe assert issue when the incorrect answer message
received.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
This commit is contained in:
Jiaxin Wu 2016-12-08 08:52:41 +08:00
parent 3f31ea1b3d
commit 0e5e7996c9
1 changed files with 17 additions and 4 deletions

View File

@ -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);