From: "Liming Gao" <liming.gao@intel.com>
To: "Marvin.Haeuser@outlook.com" <Marvin.Haeuser@outlook.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "vit9696@protonmail.com" <vit9696@protonmail.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference
Date: Mon, 21 Oct 2019 03:12:11 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E51F6CD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <DB7PR07MB4917254D22F4AA8C6B86FD98806E0@DB7PR07MB4917.eurprd07.prod.outlook.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
>Sent: Sunday, October 20, 2019 8:09 PM
>To: devel@edk2.groups.io
>Cc: vit9696@protonmail.com; Kinney, Michael D
><michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference
>
>From: Marvin Haeuser <mhaeuser@outlook.de>
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2293
>
>Move the NULL check in FileHandleGetInfo() to directly after the
>allocation to prevent potential NULL dereferences.
>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de>
>---
> MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 28 +++++++++++----
>-----
> 1 file changed, 15 insertions(+), 13 deletions(-)
>
>diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>index 96913c5c02b8..5dc893833a46 100644
>--- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>+++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>@@ -68,19 +68,21 @@ FileHandleGetInfo (
> // error is expected. getting size to allocate
>
> //
>
> FileInfo = AllocateZeroPool(FileInfoSize);
>
>- //
>
>- // now get the information
>
>- //
>
>- Status = FileHandle->GetInfo(FileHandle,
>
>- &gEfiFileInfoGuid,
>
>- &FileInfoSize,
>
>- FileInfo);
>
>- //
>
>- // if we got an error free the memory and return NULL
>
>- //
>
>- if (EFI_ERROR(Status) && (FileInfo != NULL)) {
>
>- FreePool(FileInfo);
>
>- FileInfo = NULL;
>
>+ if (FileInfo != NULL) {
>
>+ //
>
>+ // now get the information
>
>+ //
>
>+ Status = FileHandle->GetInfo(FileHandle,
>
>+ &gEfiFileInfoGuid,
>
>+ &FileInfoSize,
>
>+ FileInfo);
>
>+ //
>
>+ // if we got an error free the memory and return NULL
>
>+ //
>
>+ if (EFI_ERROR(Status)) {
>
>+ FreePool(FileInfo);
>
>+ FileInfo = NULL;
>
>+ }
>
> }
>
> }
>
> return (FileInfo);
>
>--
>2.23.0.windows.1
next prev parent reply other threads:[~2019-10-21 3:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-20 12:08 [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference Marvin Häuser
2019-10-21 3:12 ` Liming Gao [this message]
[not found] ` <15CF8AEA297AE48F.24139@groups.io>
2019-11-04 2:10 ` [edk2-devel] " Liming Gao
-- strict thread matches above, loose matches on Subject: below --
2018-05-05 20:21 Marvin Häuser
2018-05-17 8:04 ` Ni, Ruiyu
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=4A89E2EF3DFEDB4C8BFDE51014F606A14E51F6CD@SHSMSX104.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