public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guomin Jiang" <guomin.jiang@intel.com>
To: devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Andrew Fish <afish@apple.com>, Ray Ni <ray.ni@intel.com>
Subject: [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status.
Date: Fri, 20 Mar 2020 14:55:43 +0800	[thread overview]
Message-ID: <20200320065543.602-1-guomin.jiang@intel.com> (raw)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2605

I think it is necessary that check the buffer size before ReadFile, it
will inform the caller that they should provide more buffer.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 EmulatorPkg/Win/Host/WinFileSystem.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/EmulatorPkg/Win/Host/WinFileSystem.c b/EmulatorPkg/Win/Host/WinFileSystem.c
index f6b06b1c92..6fb86db6b3 100644
--- a/EmulatorPkg/Win/Host/WinFileSystem.c
+++ b/EmulatorPkg/Win/Host/WinFileSystem.c
@@ -1159,6 +1159,12 @@ WinNtFileRead (
       }
     }
 
+    if (FileSize > *BufferSize) {
+      Status = EFI_BUFFER_TOO_SMALL;
+      *BufferSize = FileSize;
+      goto Done;
+    }
+
     Status = ReadFile (
       PrivateFile->LHandle,
       Buffer,
-- 
2.25.1.windows.1


             reply	other threads:[~2020-03-20  6:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20  6:55 Guomin Jiang [this message]
2020-03-20  7:11 ` [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status Ni, Ray
2020-03-23  1:40   ` Guomin Jiang

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=20200320065543.602-1-guomin.jiang@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