From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: devel@edk2.groups.io, zhichao.gao@intel.com, "Zhang,
Shenglei" <shenglei.zhang@intel.com>
Cc: "Ni, Ray" <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer
Date: Mon, 14 Oct 2019 11:38:56 +0200 [thread overview]
Message-ID: <f1c90c55-9afd-e86c-8707-d506544b0d4a@redhat.com> (raw)
In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B8565FD@SHSMSX101.ccr.corp.intel.com>
On 10/14/19 8:35 AM, Gao, Zhichao wrote:
> Refer to CSS 5.2.2.6 Always put space before an open parenthesis.
> FreePool(AsciiBuffer); should be FreePool (AsciiBuffer);
> After address that, Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
>
> Thanks,
> Zhichao
>
>> -----Original Message-----
>> From: Zhang, Shenglei
>> Sent: Monday, October 14, 2019 9:25 AM
>> To: devel@edk2.groups.io
>> Cc: Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
>> Subject: [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for
>> MemFile->Buffer
>>
>> Add check for MemFile->Buffer.
>> Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL.
>>
>> Cc: Ray Ni <ray.ni@intel.com>
>> Cc: Zhichao Gao <zhichao.gao@intel.com>
>> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
>> ---
>>
>> v2: Add the expressiong to free AsciiBuffer before the function is returned.
>>
>> ShellPkg/Application/Shell/FileHandleWrappers.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c
>> b/ShellPkg/Application/Shell/FileHandleWrappers.c
>> index 587556c42495..2d7bd7bec67e 100644
>> --- a/ShellPkg/Application/Shell/FileHandleWrappers.c
>> +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
>> @@ -1644,6 +1644,9 @@ FileInterfaceMemWrite(
>> //
>> if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile-
>>> BufferSize)) {
>> MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize),
>> (UINTN)(MemFile->BufferSize) + (*BufferSize) +
>> MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
>> + if (MemFile->Buffer == NULL){
Also "Always put space before an open brace (curly bracket)"
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> MemFile->BufferSize += (*BufferSize) +
>> MEM_WRITE_REALLOC_OVERHEAD;
>> }
>> CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer,
>> *BufferSize); @@ -1661,6 +1664,10 @@ FileInterfaceMemWrite(
>> AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
>> if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) >
>> (UINTN)(MemFile->BufferSize)) {
>> MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize),
>> (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) +
>> MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
>> + if (MemFile->Buffer == NULL){
>> + FreePool(AsciiBuffer);
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> MemFile->BufferSize += AsciiStrSize(AsciiBuffer) +
>> MEM_WRITE_REALLOC_OVERHEAD;
>> }
>> CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer,
>> AsciiStrSize(AsciiBuffer));
>> --
>> 2.18.0.windows.1
>
>
>
>
next prev parent reply other threads:[~2019-10-14 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 1:25 [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer Zhang, Shenglei
2019-10-14 6:35 ` Gao, Zhichao
2019-10-14 9:38 ` Philippe Mathieu-Daudé [this message]
2019-10-14 14:04 ` [edk2-devel] " Zhang, Shenglei
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=f1c90c55-9afd-e86c-8707-d506544b0d4a@redhat.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