public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Li, Songpeng" <songpeng.li@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Jiaxin" <jiaxin.wu@intel.com>
Subject: Re: [PATCH 1/2] NetworkPkg/HttpDxe: fix read memory access overflow in HTTPBoot.
Date: Fri, 28 Sep 2018 02:32:37 +0000	[thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58B61DADE@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20180928015706.32068-2-songpeng.li@intel.com>

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Songpeng Li
> Sent: Friday, September 28, 2018 9:57 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [PATCH 1/2] NetworkPkg/HttpDxe: fix read memory access
> overflow in HTTPBoot.
> 
> The input param String of AsciiStrStr() requires a pointer to
>  Null-terminated string, however in HttpTcpReceiveHeader(),
>  the Buffersize before AllocateZeroPool() is equal to the size
>  of TCP header, after the CopyMem(), it might not end with
>  Null-terminator. It might cause memory access overflow.
> 
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1204
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Songpeng Li <songpeng.li@intel.com>
> ---
>  NetworkPkg/HttpDxe/HttpProto.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpProto.c
> b/NetworkPkg/HttpDxe/HttpProto.c
> index 94f89f5665..7d69429be7 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.c
> +++ b/NetworkPkg/HttpDxe/HttpProto.c
> @@ -1914,10 +1914,10 @@ HttpTcpReceiveHeader (
>        }
> 
>        //
> -      // Append the response string.
> +      // Append the response string along with a Null-terminator.
>        //
>        *BufferSize = *SizeofHeaders + Fragment.Len;
> -      Buffer      = AllocateZeroPool (*BufferSize);
> +      Buffer      = AllocatePool (*BufferSize + 1);
>        if (Buffer == NULL) {
>          Status = EFI_OUT_OF_RESOURCES;
>          return Status;
> @@ -1933,6 +1933,7 @@ HttpTcpReceiveHeader (
>          Fragment.Bulk,
>          Fragment.Len
>          );
> +      *(Buffer + *BufferSize) = '\0';
>        *HttpHeaders   = Buffer;
>        *SizeofHeaders = *BufferSize;
> 
> @@ -2013,10 +2014,10 @@ HttpTcpReceiveHeader (
>        }
> 
>        //
> -      // Append the response string.
> +      // Append the response string along with a Null-terminator.
>        //
>        *BufferSize = *SizeofHeaders + Fragment.Len;
> -      Buffer      = AllocateZeroPool (*BufferSize);
> +      Buffer      = AllocatePool (*BufferSize + 1);
>        if (Buffer == NULL) {
>          Status = EFI_OUT_OF_RESOURCES;
>          return Status;
> @@ -2032,6 +2033,7 @@ HttpTcpReceiveHeader (
>          Fragment.Bulk,
>          Fragment.Len
>          );
> +      *(Buffer + *BufferSize) = '\0';
>        *HttpHeaders   = Buffer;
>        *SizeofHeaders = *BufferSize;
> 
> --
> 2.18.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2018-09-28  2:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28  1:57 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
2018-09-28  1:57 ` [PATCH 1/2] NetworkPkg/HttpDxe: " Songpeng Li
2018-09-28  2:32   ` Fu, Siyuan [this message]
2018-09-28  1:57 ` [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow Songpeng Li
2018-09-28  2:32   ` Fu, Siyuan
  -- strict thread matches above, loose matches on Subject: below --
2018-09-25  8:24 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
2018-09-25  8:24 ` [PATCH 1/2] NetworkPkg/HttpDxe: " Songpeng Li

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=B1FF2E9001CE9041BD10B825821D5BC58B61DADE@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