X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FLs.c;h=63af5eab18884d216110df720440073607260719;hp=b5ef6aa2a9fbce870ad8a24ade61bf7121f50a14;hb=3a8406adb367e8b0d2f107adfc6c141b953d938d;hpb=e27ecde731feeeb59d9e04e25c4bd77f187b5864;ds=sidebyside diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index b5ef6aa2a9..63af5eab18 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -379,6 +379,9 @@ PrintLsOutput( } CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0); + if (CorrectedPath == NULL) { + return SHELL_OUT_OF_RESOURCES; + } if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\' &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') { CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0); @@ -666,8 +669,17 @@ ShellCommandRunLs ( ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL)); if (StrStr(PathName, L":") == NULL) { StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0); + if (FullPath == NULL) { + ShellCommandLineFreeVarList (Package); + return SHELL_OUT_OF_RESOURCES; + } } StrnCatGrow(&FullPath, &Size, PathName, 0); + if (FullPath == NULL) { + ShellCommandLineFreeVarList (Package); + return SHELL_OUT_OF_RESOURCES; + } + if (ShellIsDirectory(PathName) == EFI_SUCCESS) { // // is listing ends with a directory, then we list all files in that directory