From: "Shi, Steven" <steven.shi@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] ShellPkg: Avoid buffer out-of-bound access
Date: Fri, 28 Jul 2017 09:12:38 +0000 [thread overview]
Message-ID: <06C8AB66E78EE34A949939824ABE2B313B54C715@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170726082227.33224-1-ruiyu.ni@intel.com>
Reviewed-by: Steven Shi <steven.shi@intel.com>
Thanks
Steven Shi
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Wednesday, July 26, 2017 4:22 PM
> To: edk2-devel@lists.01.org
> Cc: Shi, Steven <steven.shi@intel.com>
> Subject: [PATCH] ShellPkg: Avoid buffer out-of-bound access
>
> PathSize is the number of bytes in PathForReturn buffer so
> PathForReturn[PathSize - 1] incorrectly accesses the last
> character in the buffer,
> PathForReturn[PathSize / sizeof (CHAR16) - 1] should be used.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Steven Shi <steven.shi@intel.com>
> ---
> ShellPkg/Application/Shell/ShellProtocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ShellPkg/Application/Shell/ShellProtocol.c
> b/ShellPkg/Application/Shell/ShellProtocol.c
> index b3b8acc0d0..991fb58ca7 100644
> --- a/ShellPkg/Application/Shell/ShellProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellProtocol.c
> @@ -477,7 +477,7 @@ EfiShellGetFilePathFromDevicePath(
> // UEFI Shell spec section 3.7)
> if ((PathSize != 0) &&
> (PathForReturn != NULL) &&
> - (PathForReturn[PathSize - 1] != L'\\') &&
> + (PathForReturn[PathSize / sizeof (CHAR16) - 1] != L'\\') &&
> (AlignedNode->PathName[0] != L'\\')) {
> PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);
> }
> --
> 2.12.2.windows.2
prev parent reply other threads:[~2017-07-28 9:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 8:22 [PATCH] ShellPkg: Avoid buffer out-of-bound access Ruiyu Ni
2017-07-28 9:12 ` Shi, Steven [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=06C8AB66E78EE34A949939824ABE2B313B54C715@shsmsx102.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