* [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe
@ 2016-12-08 0:54 Jiaxin Wu
2016-12-23 6:36 ` Zhang, Lubo
2016-12-23 7:22 ` Ye, Ting
0 siblings, 2 replies; 3+ messages in thread
From: Jiaxin Wu @ 2016-12-08 0:54 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Zhang Lubo, Wu Jiaxin
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe
2016-12-08 0:54 [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Jiaxin Wu
@ 2016-12-23 6:36 ` Zhang, Lubo
2016-12-23 7:22 ` Ye, Ting
1 sibling, 0 replies; 3+ messages in thread
From: Zhang, Lubo @ 2016-12-23 6:36 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Fu, Siyuan
Looks good to me.
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Thursday, December 08, 2016 8:55 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zhang,
> Lubo <lubo.zhang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] 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>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe
2016-12-08 0:54 [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Jiaxin Wu
2016-12-23 6:36 ` Zhang, Lubo
@ 2016-12-23 7:22 ` Ye, Ting
1 sibling, 0 replies; 3+ messages in thread
From: Ye, Ting @ 2016-12-23 7:22 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Fu, Siyuan, Zhang, Lubo
Reviewed-by: Ye Ting <ting.ye@intel.com>
-----Original Message-----
From: Wu, Jiaxin
Sent: Thursday, December 08, 2016 8:55 AM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zhang, Lubo <lubo.zhang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] 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>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-23 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-08 0:54 [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe Jiaxin Wu
2016-12-23 6:36 ` Zhang, Lubo
2016-12-23 7:22 ` Ye, Ting
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox