Refine the code in UiApp to prevent the potential risk.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Application/UiApp/BootMaint/FileExplorer.c |  1 -
 MdeModulePkg/Application/UiApp/BootMaint/Variable.c     | 12 ++++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Application/UiApp/BootMaint/FileExplorer.c 
b/MdeModulePkg/Application/UiApp/BootMaint/FileExplorer.c
index b459fba..e2e6b03 100644
--- a/MdeModulePkg/Application/UiApp/BootMaint/FileExplorer.c
+++ b/MdeModulePkg/Application/UiApp/BootMaint/FileExplorer.c
@@ -256,11 +256,10 @@ FileExplorerCallback (
     return EFI_UNSUPPORTED;
   }
 
   Status         = EFI_SUCCESS;
   Private        = FE_CALLBACK_DATA_FROM_THIS (This);
-  *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
 
   //
   // Retrieve uncommitted data from Form Browser
   //
   NvRamMap = &Private->FeFakeNvData;
diff --git a/MdeModulePkg/Application/UiApp/BootMaint/Variable.c 
b/MdeModulePkg/Application/UiApp/BootMaint/Variable.c
index 5e5592f..805387f 100644
--- a/MdeModulePkg/Application/UiApp/BootMaint/Variable.c
+++ b/MdeModulePkg/Application/UiApp/BootMaint/Variable.c
@@ -522,10 +522,11 @@ Var_UpdateErrorOutOption (
   @param OptionalData    The optional load option.
   @param ForceReconnect  If to force reconnect.
 
   @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
   @retval EFI_SUCCESS          If function completes successfully.
+  @return Others Errors        Return errors from call to gRT->GetVariable.
 
 **/
 EFI_STATUS
 Var_UpdateDriverOption (
   IN  BMM_CALLBACK_DATA         *CallbackData,
@@ -657,11 +658,14 @@ Var_UpdateDriverOption (
                   VAR_FLAG,
                   BufferSize,
                   Buffer
                   );
   ASSERT_EFI_ERROR (Status);
-  GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, 
&DriverOrderListSize);
+  Status = GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, 
&DriverOrderListSize);
+  if (EFI_ERROR (Status) || DriverOrderList == NULL){
+    return Status;
+  }
   NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof 
(UINT16));
   ASSERT (NewDriverOrderList != NULL);
   CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);
   NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;
   if (DriverOrderList != NULL) {
@@ -698,10 +702,11 @@ Var_UpdateDriverOption (
   @param CallbackData    The BMM context data.
   @param NvRamMap        The file explorer formset internal state.
 
   @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
   @retval EFI_SUCCESS          If function completes successfully.
+  @return Others Errors        Return errors from call to gRT->GetVariable.
 
 **/
 EFI_STATUS
 Var_UpdateBootOption (
   IN  BMM_CALLBACK_DATA                   *CallbackData,
@@ -822,11 +827,14 @@ Var_UpdateBootOption (
                   BufferSize,
                   Buffer
                   );
   ASSERT_EFI_ERROR (Status);
 
-  GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, 
&BootOrderListSize);
+  Status = GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, 
&BootOrderListSize);
+  if (EFI_ERROR (Status) || BootOrderList == NULL){
+    return Status;
+  }
   NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));
   ASSERT (NewBootOrderList != NULL);
   CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);
   NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to