]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix handling of empty files in Hexedit
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 29 Nov 2011 15:37:04 +0000 (15:37 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 29 Nov 2011 15:37:04 +0000 (15:37 +0000)
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

index ff3819c6c61aac604acc3230c73697dd9868a8c7..ccf5406645ac0c4e2f50e08621a16e929a0dc155 100644 (file)
@@ -169,7 +169,10 @@ HFileImageRead (
   // you should set the status string\r
   //\r
   Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);\r
-  if (EFI_ERROR(Status) || Buffer == NULL) {\r
+  //\r
+  // NULL pointer is only also a failure for a non-zero file size.\r
+  //\r
+  if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) {\r
     UnicodeBuffer = CatSPrint(NULL, L"Read error on file &s: %r", FileName, Status);\r
     if (UnicodeBuffer == NULL) {\r
       SHELL_FREE_NON_NULL(Buffer);\r