public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: "Fu, Siyuan" <siyuan.fu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ye, Ting" <ting.ye@intel.com>,
	Michael Turner <Michael.Turner@microsoft.com>
Subject: Re: [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf.
Date: Wed, 20 Sep 2017 08:16:50 +0000	[thread overview]
Message-ID: <895558F6EA4E3B41AC93A00D163B727416335C65@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20170920032357.5864-1-siyuan.fu@intel.com>

Hi Siyuan,

Maybe we can add more check for the Len to return directly, what do you think?

  if (Len == 0) {
    return 0;
  }

> +  if (Nbuf->TotalSize == 0) {
> +    return 0;
> +  }

Thanks,
Jiaxin


> -----Original Message-----
> From: Fu, Siyuan
> Sent: Wednesday, September 20, 2017 11:24 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Michael
> Turner <Michael.Turner@microsoft.com>
> Subject: [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size
> before trim data from Nbuf.
> 
> In NetbufTrim() function, the NetBuf TotalSize should be checked with 0
> before
> making the trim operation, otherwise the function will fall into infinite loop.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> ---
>  MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> index 95cb71714b..25fc78e49e 100644
> --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> @@ -1175,6 +1175,10 @@ NetbufTrim (
> 
>    NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
> 
> +  if (Nbuf->TotalSize == 0) {
> +    return 0;
> +  }
> +
>    if (Len > Nbuf->TotalSize) {
>      Len = Nbuf->TotalSize;
>    }
> --
> 2.13.0.windows.1



      reply	other threads:[~2017-09-20  8:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20  3:23 [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf Fu Siyuan
2017-09-20  8:16 ` Wu, Jiaxin [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=895558F6EA4E3B41AC93A00D163B727416335C65@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