From 2e5c97edcd06f12034af3bf6684c63a2d8275315 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Tue, 29 Nov 2011 15:37:04 +0000 Subject: ShellPkg: Fix handling of empty files in Hexedit Currently hexedit thinks all files that are non-existent (i.e. new) or empty must be a memory error since the pointer is checked, but the file size is not referenced. Signed-off-by: jcarsey Reviewed-by: jljusten git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12797 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c index ff3819c6c6..ccf5406645 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c @@ -169,7 +169,10 @@ HFileImageRead ( // you should set the status string // Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly); - if (EFI_ERROR(Status) || Buffer == NULL) { + // + // NULL pointer is only also a failure for a non-zero file size. + // + if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) { UnicodeBuffer = CatSPrint(NULL, L"Read error on file &s: %r", FileName, Status); if (UnicodeBuffer == NULL) { SHELL_FREE_NON_NULL(Buffer); -- cgit v1.2.3