summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorShumin Qiu <shumin.qiu@intel.com>2014-02-25 08:30:32 +0000
committershenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524>2014-02-25 08:30:32 +0000
commit3a8406adb367e8b0d2f107adfc6c141b953d938d (patch)
treec9173f2f10ed5b56e6f4877a1ab449c1f7be1008 /ShellPkg
parente27ecde731feeeb59d9e04e25c4bd77f187b5864 (diff)
downloadedk2-platforms-3a8406adb367e8b0d2f107adfc6c141b953d938d.tar.xz
Add code to check whether the pointer 'CorrectedPath' and 'FullPath' are NULL before used.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shumin Qiu <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15260 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c12
1 files changed, 12 insertions, 0 deletions
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