From 4f344fffc7fb541d11edf4cf657f84549b334244 Mon Sep 17 00:00:00 2001 From: Shumin Qiu Date: Fri, 7 Mar 2014 01:06:37 +0000 Subject: [PATCH] 1.Add code to check the pointer 'CorrectedPath' in Ls.c line 460 before referenced. 2.Not use explicit comparisons to TRUE or FALSE for Boolean variable in Ls.c. 3.Add doxygen tags in comment and return type for 'ToLower' in ShellProtocol.c. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shumin Qiu Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15320 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ShellProtocol.c | 8 ++++++-- ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 116e3f2060..65c3c46a46 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -2995,9 +2995,12 @@ InternalEfiShellGetListAlias( /** Convert a null-terminated unicode string, in-place, to all lowercase. Then return it. + + @param Str The null-terminated string to be converted to all lowercase. + + @return The null-terminated string converted into all lowercase. **/ -STATIC -CHAR16 * +STATIC CHAR16 * ToLower ( CHAR16 *Str ) @@ -3538,3 +3541,4 @@ InernalEfiShellStartMonitor( } return (Status); } + diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index 63af5eab18..64ce4ae2c0 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -437,7 +437,7 @@ PrintLsOutput( } } - if (!Sfo && HeaderPrinted == FALSE) { + if (!Sfo && !HeaderPrinted) { PrintNonSfoHeader(CorrectedPath); } PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount); @@ -457,6 +457,9 @@ PrintLsOutput( ShellCloseFileMetaArg(&ListHead); CorrectedPath[0] = CHAR_NULL; 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); @@ -498,7 +501,7 @@ PrintLsOutput( SHELL_FREE_NON_NULL(CorrectedPath); ShellCloseFileMetaArg(&ListHead); - if (Found == NULL && FoundOne == FALSE) { + if (Found == NULL && !FoundOne) { return (SHELL_NOT_FOUND); } -- 2.39.2