X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FLs.c;h=9b4c452ca3540b1d4f79adc4856630d09ffb15d1;hb=795c78cf190ba7ac3e7edd76e6c31b8505c2d739;hp=25bf8ca9e13a124a40ac33bf2293b45e27536f41;hpb=fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index 25bf8ca9e1..9b4c452ca3 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -2,7 +2,7 @@ Main file for ls shell level 2 function. (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -442,6 +442,7 @@ PrintLsOutput( } if (!Sfo && !HeaderPrinted) { + PathRemoveLastItem (CorrectedPath); PrintNonSfoHeader(CorrectedPath); } PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount); @@ -707,10 +708,14 @@ ShellCommandRunLs ( // // must split off the search part that applies to files from the end of the directory part // - for (StrnCatGrow(&SearchString, NULL, PathName, 0) - ; SearchString != NULL && StrStr(SearchString, L"\\") != NULL - ; CopyMem(SearchString, StrStr(SearchString, L"\\") + 1, 1 + StrSize(StrStr(SearchString, L"\\") + 1))) ; - FullPath[StrLen(FullPath) - StrLen(SearchString)] = CHAR_NULL; + StrnCatGrow(&SearchString, NULL, FullPath, 0); + if (SearchString == NULL) { + FreePool (FullPath); + ShellCommandLineFreeVarList (Package); + return SHELL_OUT_OF_RESOURCES; + } + PathRemoveLastItem (FullPath); + CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath))); } } }