public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status.
@ 2020-03-20  6:55 Guomin Jiang
  2020-03-20  7:11 ` Ni, Ray
  0 siblings, 1 reply; 3+ messages in thread
From: Guomin Jiang @ 2020-03-20  6:55 UTC (permalink / raw)
  To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-23  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-20  6:55 [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status Guomin Jiang
2020-03-20  7:11 ` Ni, Ray
2020-03-23  1:40   ` Guomin Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox