summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c2
-rw-r--r--ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c5
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c10
3 files changed, 14 insertions, 3 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 3371e58b11..17c517c088 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -1799,7 +1799,7 @@ CreateAndPopulateShellFileInfo(
if (ShellFileListItem == NULL) {
return (NULL);
}
- if (Info != NULL) {
+ if (Info != NULL && Info->Size != 0) {
ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size);
if (ShellFileListItem->Info == NULL) {
FreePool(ShellFileListItem);
diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 0bee8e3899..fb9d4ec0be 100644
--- a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -509,9 +509,12 @@ FileHandleFindFirstFile (
//
Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status) || BufferSize == 0) {
FreePool(*Buffer);
*Buffer = NULL;
+ if (BufferSize == 0) {
+ return (EFI_NOT_FOUND);
+ }
return (Status);
}
return (EFI_SUCCESS);
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 3799341425..55267a467a 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -66,14 +66,22 @@ PrintLsOutput(
CorrectedPath = NULL;
CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);
- ASSERT(CorrectedPath != NULL);
+ if (CorrectedPath == NULL) {
+ return (SHELL_OUT_OF_RESOURCES);
+ }
+
PathCleanUpDirectories(CorrectedPath);
Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
if (EFI_ERROR(Status)) {
+ SHELL_FREE_NON_NULL(CorrectedPath);
+ if(Status == EFI_NOT_FOUND){
+ return (SHELL_NOT_FOUND);
+ }
return (SHELL_DEVICE_ERROR);
}
if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
+ SHELL_FREE_NON_NULL(CorrectedPath);
//
// On the first one only we expect to find something...
// do we find the . and .. directories otherwise?