From: "Zhiguang Liu" <zhiguang.liu@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"vladimir.olovyannikov@broadcom.com"
<vladimir.olovyannikov@broadcom.com>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg : UefiFileHandleLib: fix buffer overrun in FileHandleReadLine()
Date: Fri, 3 Jul 2020 02:30:44 +0000 [thread overview]
Message-ID: <CY4PR11MB16873F1AAF3A67DB15059EE7906A0@CY4PR11MB1687.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200702023113.10517-1-vladimir.olovyannikov@broadcom.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vladimir
> Olovyannikov via groups.io
> Sent: Thursday, July 2, 2020 10:31 AM
> To: devel@edk2.groups.io
> Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: [edk2-devel] [PATCH v2 1/1] MdePkg : UefiFileHandleLib: fix buffer
> overrun in FileHandleReadLine()
>
> If the size of the supplied buffer in FileHandleReadLine(), module
> UefiFileHandleLib.c, was not 0, but was not enough to fit in
> the line, the size is increased, and then the Buffer of the new
> size is zeroed. This size is always larger than the supplied buffer size,
> causing supplied buffer overrun. Fix the issue by using the
> supplied buffer size in ZeroMem().
>
> Signed-off-by: Vladimir Olovyannikov
> <vladimir.olovyannikov@broadcom.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> index 28e28e5f67d5..ab34e6ccd5f4 100644
> --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
> @@ -969,6 +969,7 @@ FileHandleReadLine(
> UINTN CharSize;
>
> UINTN CountSoFar;
>
> UINTN CrCount;
>
> + UINTN OldSize;
>
> UINT64 OriginalFilePosition;
>
>
>
> if (Handle == NULL
>
> @@ -1039,10 +1040,11 @@ FileHandleReadLine(
> // if we ran out of space tell when...
>
> //
>
> if ((CountSoFar+1-CrCount)*sizeof(CHAR16) > *Size){
>
> + OldSize = *Size;
>
> *Size = (CountSoFar+1-CrCount)*sizeof(CHAR16);
>
> if (!Truncate) {
>
> - if (Buffer != NULL && *Size != 0) {
>
> - ZeroMem(Buffer, *Size);
>
> + if (Buffer != NULL && OldSize != 0) {
>
> + ZeroMem(Buffer, OldSize);
>
> }
>
> FileHandleSetPosition(Handle, OriginalFilePosition);
>
> return (EFI_BUFFER_TOO_SMALL);
>
> --
> 2.26.2.266.ge870325ee8
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
>
> View/Reply Online (#61938): https://edk2.groups.io/g/devel/message/61938
> Mute This Topic: https://groups.io/mt/75251007/1779286
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub
> [zhiguang.liu@intel.com]
> -=-=-=-=-=-=
next prev parent reply other threads:[~2020-07-03 2:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 2:31 [PATCH v2 1/1] MdePkg : UefiFileHandleLib: fix buffer overrun in FileHandleReadLine() Vladimir Olovyannikov
2020-07-03 2:30 ` Zhiguang Liu [this message]
2020-08-24 16:18 ` [edk2-devel] " Laszlo Ersek
2020-08-24 16:52 ` Laszlo Ersek
2020-08-25 4:20 ` Vladimir Olovyannikov
2020-08-26 10:03 ` Laszlo Ersek
2020-08-26 16:05 ` Vladimir Olovyannikov
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=CY4PR11MB16873F1AAF3A67DB15059EE7906A0@CY4PR11MB1687.namprd11.prod.outlook.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