summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2018-02-05 15:53:20 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-02-06 17:30:24 +0800
commit7162fdb037fb9385f6bd7d0dc55d54029b810de2 (patch)
tree4188a7f228483caf91b2a8cbd039936bcd7ab3f8
parente0db09cd1cd35a1e2ae627e305d903652555aef2 (diff)
downloadedk2-7162fdb037fb9385f6bd7d0dc55d54029b810de2.zip
edk2-7162fdb037fb9385f6bd7d0dc55d54029b810de2.tar.gz
edk2-7162fdb037fb9385f6bd7d0dc55d54029b810de2.tar.bz2
ShellPkg/for: Fix potential null pointer deference
When "FOR %a %a IN A B C" is executed, CurrentScriptFile->CurrentCommand->Data is NULL. But the code assumes it's not NULL and tries to deference it. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index 3db4bb5..9824977 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -2,7 +2,7 @@
Main file for endfor and for shell level 1 functions.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
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
@@ -624,7 +624,9 @@ ShellCommandRunFor (
if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) {
Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;
if (CurrentScriptFile->CurrentCommand->Reset) {
- Info->CurrentValue = (CHAR16*)Info->Set;
+ if (Info != NULL) {
+ Info->CurrentValue = (CHAR16*)Info->Set;
+ }
FirstPass = TRUE;
CurrentScriptFile->CurrentCommand->Reset = FALSE;
}