public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Carsey, Jaben" <jaben.carsey@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] ShellPkg/map: Fix out-of-bound read when "map fsn"
Date: Mon, 5 Feb 2018 15:00:51 +0000	[thread overview]
Message-ID: <CB6E33457884FA40993F35157061515CA3C4E7B2@FMSMSX103.amr.corp.intel.com> (raw)
In-Reply-To: <20180205054953.212680-1-ruiyu.ni@intel.com>

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Sunday, February 04, 2018 9:50 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> Subject: [PATCH] ShellPkg/map: Fix out-of-bound read when "map fsn"
> Importance: High
> 
> The below code reads additional one CHAR16 when copying
> content from Specific to NewSpecific.
> NewSpecific = AllocateCopyPool(
>                 StrSize(Specific) + sizeof(CHAR16), Specific
>                 );
> 
> The patch fixes this issue.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> ---
>  ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c | 18 ++++++++++++--
> ----
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
> index 3f5925f507..9166ca2205 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Main file for map shell level 2 command.
> 
> -  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>    (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
>    (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> 
> @@ -220,19 +220,25 @@ MappingListHasType(
>    IN CONST BOOLEAN    Consist
>    )
>  {
> -  CHAR16 *NewSpecific;
> -  RETURN_STATUS  Status;
> +  CHAR16              *NewSpecific;
> +  RETURN_STATUS       Status;
> +  UINTN               Length;
> 
>    //
>    // specific has priority
>    //
>    if (Specific != NULL) {
> -    NewSpecific = AllocateCopyPool(StrSize(Specific) + sizeof(CHAR16),
> Specific);
> +    Length      = StrLen (Specific);
> +    //
> +    // Allocate enough buffer for Specific and potential ":"
> +    //
> +    NewSpecific = AllocatePool ((Length + 2) * sizeof(CHAR16));
>      if (NewSpecific == NULL){
>        return FALSE;
>      }
> -    if (NewSpecific[StrLen(NewSpecific)-1] != L':') {
> -      Status = StrnCatS(NewSpecific, (StrSize(Specific) +
> sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
> +    StrCpyS (NewSpecific, Length + 2, Specific);
> +    if (Specific[Length - 1] != L':') {
> +      Status = StrnCatS(NewSpecific, Length + 2, L":", StrLen(L":"));
>        if (EFI_ERROR (Status)) {
>          FreePool(NewSpecific);
>          return FALSE;
> --
> 2.16.1.windows.1



      reply	other threads:[~2018-02-05 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05  5:49 [PATCH] ShellPkg/map: Fix out-of-bound read when "map fsn" Ruiyu Ni
2018-02-05 15:00 ` Carsey, Jaben [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=CB6E33457884FA40993F35157061515CA3C4E7B2@FMSMSX103.amr.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