]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
Refine code to make it more safely.
[mirror_edk2.git] / ShellPkg / Library / UefiShellInstall1CommandsLib / Bcfg.c
index b91b34ffaeb1cc544509044629fdb8f3b1ebd270..a7893f5eeede79f85e938ca467b8611e49eaa816 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for bcfg shell Install1 function.\r
 \r
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2014, 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
@@ -1040,8 +1040,12 @@ BcfgDisplayDumpInstall1(
 \r
     if ((*(UINT16*)(Buffer+4)) != 0) {\r
       DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));\r
-      CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));\r
-      DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);\r
+      if (DevPath == NULL) {\r
+        DevPathString = NULL;\r
+      } else {\r
+        CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));\r
+        DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);\r
+      }\r
     } else {\r
       DevPath       = NULL;\r
       DevPathString = NULL;\r
@@ -1211,12 +1215,16 @@ ShellCommandRunBcfgInstall (
         CurrentOperation.Order);\r
       if (Status == EFI_BUFFER_TOO_SMALL) {\r
         CurrentOperation.Order = AllocateZeroPool(Length+(4*sizeof(CurrentOperation.Order[0])));\r
-        Status = gRT->GetVariable(\r
-          CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
-          (EFI_GUID*)&gEfiGlobalVariableGuid,\r
-          NULL,\r
-          &Length,\r
-          CurrentOperation.Order);\r
+        if (CurrentOperation.Order == NULL) {\r
+          ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+        } else {\r
+          Status = gRT->GetVariable(\r
+            CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
+            (EFI_GUID*)&gEfiGlobalVariableGuid,\r
+            NULL,\r
+            &Length,\r
+            CurrentOperation.Order);\r
+        }\r
       }\r
     }\r
 \r