]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/for: Fix potential null pointer deference
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 5 Feb 2018 07:53:20 +0000 (15:53 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 6 Feb 2018 09:30:24 +0000 (17:30 +0800)
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>
ShellPkg/Library/UefiShellLevel1CommandsLib/For.c

index 3db4bb58d388fecb1cffdebc600c2207184de9d1..9824977149193ebab07c8c1420e80a991340c67b 100644 (file)
@@ -2,7 +2,7 @@
   Main file for endfor and for shell level 1 functions.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -624,7 +624,9 @@ ShellCommandRunFor (
   if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) {\r
     Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;\r
     if (CurrentScriptFile->CurrentCommand->Reset) {\r
-      Info->CurrentValue  = (CHAR16*)Info->Set;\r
+      if (Info != NULL) {\r
+        Info->CurrentValue = (CHAR16*)Info->Set;\r
+      }\r
       FirstPass = TRUE;\r
       CurrentScriptFile->CurrentCommand->Reset = FALSE;\r
     }\r