Add code to check whether the pointer 'NewBuffer' in 'FileHandelWrappers.c' and...
authorShumin Qiu <shumin.qiu@intel.com>
Thu, 9 Jan 2014 00:30:27 +0000 (00:30 +0000)
committershenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 9 Jan 2014 00:30:27 +0000 (00:30 +0000)
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@15060 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c

index ef8293c1de511914e690d5b1dc3028e6a2585a9e..c67ddfc2698f72e11df9e6f10bfa677ed60c6258 100644 (file)
@@ -2,7 +2,7 @@
   EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables,\r
   StdIn, StdOut, StdErr, etc...).\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -973,7 +973,7 @@ FileInterfaceEnvClose(
     Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);\r
   }\r
   \r
-  if (!EFI_ERROR(Status)) {\r
+  if (!EFI_ERROR(Status) && NewBuffer != NULL) {\r
     \r
     if (StrSize(NewBuffer) > 6)\r
     {\r
index afeedb09591ec95aef652b954a8476ad9d4cce66..b02048302e6d64cc387667892507a1259a1c646d 100644 (file)
@@ -121,11 +121,15 @@ CascadeProcessVariables (
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     SHELL_FREE_NON_NULL(FoundVarName);\r
     FoundVarName = AllocateZeroPool (NameSize);\r
-    if (PrevName != NULL) {\r
-      StrCpy(FoundVarName, PrevName);\r
-    }\r
+    if (FoundVarName != NULL) {\r
+      if (PrevName != NULL) {\r
+        StrCpy(FoundVarName, PrevName);\r
+      }\r
 \r
-    Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);\r
+      Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);\r
+    } else {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
   //\r