return FALSE;\r
}\r
\r
- while (!EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {\r
+ while (EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {\r
Udp->Poll (Udp);\r
\r
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&\r
return FALSE;\r
}\r
\r
- while (!EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {\r
+ while (EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {\r
Udp->Poll (Udp);\r
\r
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip6Mode, NULL, NULL))) {\r
//\r
if (DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR || DnsHeader->AnswersNum < 1 || \\r
DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE) {\r
- Status = EFI_ABORTED;\r
- goto ON_EXIT;\r
+ //\r
+ // The domain name referenced in the query does not exist.\r
+ //\r
+ if (DnsHeader->Flags.Bits.RCode == DNS_FLAGS_RCODE_NAME_ERROR) {\r
+ Status = EFI_NOT_FOUND; \r
+ } else {\r
+ Status = EFI_DEVICE_ERROR;\r
+ }\r
+ \r
+ goto ON_COMPLETE;\r
}\r
\r
//\r
//\r
while (AnswerSectionNum < DnsHeader->AnswersNum) {\r
//\r
- // Answer name should be PTR.\r
+ // Answer name should be PTR, else EFI_UNSUPPORTED returned.\r
//\r
- ASSERT ((*(UINT8 *) AnswerName & 0xC0) == 0xC0);\r
+ if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto ON_EXIT;\r
+ }\r
\r
//\r
// Get Answer section.\r
//\r
// This is address entry, get Data.\r
//\r
- ASSERT (Dns4TokenEntry != NULL && AnswerSection->DataLength == 4);\r
+ ASSERT (Dns4TokenEntry != NULL);\r
+\r
+ if (AnswerSection->DataLength != 4) {\r
+ Status = EFI_ABORTED;\r
+ goto ON_EXIT;\r
+ }\r
\r
HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;\r
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);\r
CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));\r
\r
- //\r
- // Update DNS cache dynamically.\r
- //\r
- if (Dns4CacheEntry != NULL) {\r
- if (Dns4CacheEntry->HostName != NULL) {\r
- FreePool (Dns4CacheEntry->HostName);\r
- }\r
-\r
- if (Dns4CacheEntry->IpAddress != NULL) {\r
- FreePool (Dns4CacheEntry->IpAddress);\r
- }\r
- \r
- FreePool (Dns4CacheEntry);\r
- }\r
-\r
// \r
- // Allocate new CacheEntry pool.\r
+ // Allocate new CacheEntry pool to update DNS cache dynamically.\r
//\r
Dns4CacheEntry = AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY));\r
if (Dns4CacheEntry == NULL) {\r
Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);\r
}\r
\r
- UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry); \r
+ UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry);\r
+\r
+ // \r
+ // Free allocated CacheEntry pool.\r
+ //\r
+ FreePool (Dns4CacheEntry->HostName);\r
+ Dns4CacheEntry->HostName = NULL;\r
+ \r
+ FreePool (Dns4CacheEntry->IpAddress);\r
+ Dns4CacheEntry->IpAddress = NULL;\r
+\r
+ FreePool (Dns4CacheEntry);\r
+ Dns4CacheEntry = NULL;\r
\r
IpCount ++;\r
Status = EFI_SUCCESS;\r
//\r
// This is address entry, get Data.\r
//\r
- ASSERT (Dns6TokenEntry != NULL && AnswerSection->DataLength == 16);\r
+ ASSERT (Dns6TokenEntry != NULL);\r
+\r
+ if (AnswerSection->DataLength != 16) {\r
+ Status = EFI_ABORTED;\r
+ goto ON_EXIT;\r
+ }\r
\r
HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;\r
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);\r
CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));\r
\r
- //\r
- // Update DNS cache dynamically.\r
- //\r
- if (Dns6CacheEntry != NULL) {\r
- if (Dns6CacheEntry->HostName != NULL) {\r
- FreePool (Dns6CacheEntry->HostName);\r
- }\r
-\r
- if (Dns6CacheEntry->IpAddress != NULL) {\r
- FreePool (Dns6CacheEntry->IpAddress);\r
- }\r
- \r
- FreePool (Dns6CacheEntry);\r
- }\r
-\r
// \r
- // Allocate new CacheEntry pool.\r
+ // Allocate new CacheEntry pool to update DNS cache dynamically.\r
//\r
Dns6CacheEntry = AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY));\r
if (Dns6CacheEntry == NULL) {\r
Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);\r
}\r
\r
- UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry); \r
+ UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry);\r
+\r
+ // \r
+ // Free allocated CacheEntry pool.\r
+ //\r
+ FreePool (Dns6CacheEntry->HostName);\r
+ Dns6CacheEntry->HostName = NULL;\r
+ \r
+ FreePool (Dns6CacheEntry->IpAddress);\r
+ Dns6CacheEntry->IpAddress = NULL;\r
+\r
+ FreePool (Dns6CacheEntry);\r
+ Dns6CacheEntry = NULL;\r
\r
IpCount ++;\r
Status = EFI_SUCCESS;\r
}\r
}\r
}\r
-\r
+ \r
+ON_COMPLETE:\r
//\r
// Parsing is complete, free the sending packet and signal Event here.\r
//\r
}\r
}\r
\r
- // \r
- // Free allocated CacheEntry pool.\r
- //\r
- if (Dns4CacheEntry != NULL) {\r
- if (Dns4CacheEntry->HostName != NULL) {\r
- FreePool (Dns4CacheEntry->HostName);\r
- }\r
-\r
- if (Dns4CacheEntry->IpAddress != NULL) {\r
- FreePool (Dns4CacheEntry->IpAddress);\r
- }\r
-\r
- FreePool (Dns4CacheEntry);\r
- }\r
- \r
- if (Dns6CacheEntry != NULL) {\r
- if (Dns6CacheEntry->HostName != NULL) {\r
- FreePool (Dns6CacheEntry->HostName);\r
- }\r
-\r
- if (Dns6CacheEntry->IpAddress != NULL) {\r
- FreePool (Dns6CacheEntry->IpAddress);\r
- }\r
- \r
- FreePool (Dns6CacheEntry);\r
- }\r
-\r
ON_EXIT:\r
gBS->RestoreTPL (OldTpl);\r
return Status;\r