]> git.proxmox.com Git - mirror_edk2.git/commitdiff
For BdsDxe module,
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 21 May 2010 07:40:24 +0000 (07:40 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 21 May 2010 07:40:24 +0000 (07:40 +0000)
1. Fix the risk that local variable is pointed by global pointer, which may be used outside the variable scope.
2. Add more checking for pointers.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10536 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c

index 0eb30f0d31a7ee0cc98e2d19ac13d0c3da403d81..1ca93fd8866a28c77737ee58d6291c9933daf808 100644 (file)
@@ -1388,6 +1388,8 @@ BOpt_GetOptionNumber (
                           &gEfiGlobalVariableGuid,\r
                           &OrderListSize\r
                           );\r
+  ASSERT (OrderList != NULL);\r
+\r
   for (OptionNumber = 0; ; OptionNumber++) {\r
     for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {\r
       if (OptionNumber == OrderList[Index]) {\r
index 2ae2f96689da964a0d1ba9627c50185bf01025fa..c7d6bc4ad1b5c0e72f6044a9053b15492d38552a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Variable operation that will be used by bootmaint\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -1162,6 +1162,8 @@ Var_UpdateBBSOption (
       break;\r
     }\r
   }\r
+  ASSERT (LegacyDeviceContext != NULL);\r
+\r
   //\r
   // Update the Variable "LegacyDevOrder"\r
   //\r
index 01ff5f88adc07d62b5eef7344df5e19dffc43cf1..da291000bc360fd4f2dd38fae5da761402fc1e95 100644 (file)
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 UINT16             mKeyInput;\r
 EFI_GUID           mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;\r
-LIST_ENTRY         *mBootOptionsList;\r
+LIST_ENTRY         mBootOptionsList;\r
 BDS_COMMON_OPTION  *gOption;\r
 \r
 HII_VENDOR_DEVICE_PATH  mBootManagerHiiVendorDevicePath = {\r
@@ -97,7 +97,7 @@ BootManagerCallback (
   //\r
   KeyCount = 0;\r
 \r
-  for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) {\r
+  for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
     Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
 \r
     KeyCount++;\r
@@ -190,7 +190,6 @@ CallBootManager (
   UINTN                       ExitDataSize;\r
   EFI_STRING_ID               Token;\r
   EFI_INPUT_KEY               Key;\r
-  LIST_ENTRY                  BdsBootOptionList;\r
   CHAR16                      *HelpString;\r
   EFI_STRING_ID               HelpToken;\r
   UINT16                      *TempStr;\r
@@ -203,7 +202,7 @@ CallBootManager (
   EFI_IFR_GUID_LABEL          *EndLabel;\r
 \r
   gOption = NULL;\r
-  InitializeListHead (&BdsBootOptionList);\r
+  InitializeListHead (&mBootOptionsList);\r
 \r
   //\r
   // Connect all prior to entering the platform setup menu.\r
@@ -212,14 +211,8 @@ CallBootManager (
     BdsLibConnectAllDriversToAllControllers ();\r
     gConnectAllHappened = TRUE;\r
   }\r
-  //\r
-  // BugBug: Here we can not remove the legacy refresh macro, so we need\r
-  // get the boot order every time from "BootOrder" variable.\r
-  // Recreate the boot option list base on the BootOrder variable\r
-  //\r
-  BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
 \r
-  mBootOptionsList  = &BdsBootOptionList;\r
+  BdsLibEnumerateAllBootOption (&mBootOptionsList);\r
 \r
   HiiHandle = gBootManagerPrivate.HiiHandle;\r
 \r
@@ -248,7 +241,7 @@ CallBootManager (
 \r
   mKeyInput = 0;\r
 \r
-  for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) {\r
+  for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
     Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
 \r
     //\r
index b6cf4539af75e38f5805ab30ecac2fce70bed2e8..da0a2eef5aa9ff6842acc457c473dacdfc9cb2be 100644 (file)
@@ -2,7 +2,7 @@
   Provides a way for 3rd party applications to register themselves for launch by the\r
   Boot Manager based on hot key\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -132,6 +132,7 @@ RegisterHotkey (
                    &gEfiGlobalVariableGuid,\r
                    &TempOptionSize\r
                    );\r
+    ASSERT (TempOption != NULL);\r
 \r
     if (CompareMem (TempOption, KeyOption, TempOptionSize) == 0) {\r
       //\r