public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ye, Ting" <ting.ye@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Fu, Siyuan" <siyuan.fu@intel.com>, "Zhang, Lubo" <lubo.zhang@intel.com>
Subject: Re: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe
Date: Fri, 23 Dec 2016 07:22:06 +0000	[thread overview]
Message-ID: <BC0C045B0E2A584CA4575E779FA2C12A1A8A1D21@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1481158485-25936-1-git-send-email-jiaxin.wu@intel.com>

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



      parent reply	other threads:[~2016-12-23  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BC0C045B0E2A584CA4575E779FA2C12A1A8A1D21@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox