]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
Fix issue from code scrub.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / UpdatePage.c
index 486f2fdcfc52ba786da688c3878cc343475be322..9fa2556cd5029e60b6ee7706f0878bee33608237 100644 (file)
@@ -162,6 +162,7 @@ BootThisFile (
   BDS_COMMON_OPTION *Option;\r
 \r
   Option = (BDS_COMMON_OPTION *) AllocatePool (sizeof (BDS_COMMON_OPTION));\r
+  ASSERT (Option != NULL);\r
   Option->Description     = FileContext->FileName;\r
   Option->DevicePath      = FileContext->DevicePath;\r
   Option->LoadOptionsSize = 0;\r
@@ -236,6 +237,7 @@ UpdateBootDelPage (
   UpdatePageStart (CallbackData);\r
   CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
 \r
+  ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.BootOptionDel) / sizeof (CallbackData->BmmFakeNvData.BootOptionDel[0])));\r
   for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
     NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
     NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
@@ -316,7 +318,8 @@ UpdateDrvDelPage (
   UpdatePageStart (CallbackData);\r
 \r
   CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &DriverOptionMenu);\r
-\r
+  \r
+  ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionDel) / sizeof (CallbackData->BmmFakeNvData.DriverOptionDel[0])));\r
   for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
     NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
 \r
@@ -434,6 +437,7 @@ UpdateConsolePage (
 \r
   UpdatePageStart (CallbackData);\r
 \r
+  ASSERT (ConsoleMenu->MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.ConsoleCheck) / sizeof (CallbackData->BmmFakeNvData.ConsoleCheck[0])));\r
   for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
     NewMenuEntry      = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
     NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
@@ -518,10 +522,11 @@ UpdateOrderPage (
   ZeroMem (CallbackData->BmmFakeNvData.OptionOrder, 100);\r
 \r
   IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * OptionMenu->MenuNumber);\r
-  if (NULL == IfrOptionList) {\r
+  if (IfrOptionList == NULL) {\r
     return ;\r
   }\r
-\r
+  \r
+  ASSERT (OptionMenu->MenuNumber <= (sizeof (IfrOptionList) / sizeof (IfrOptionList[0])));\r
   for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
     NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);\r
     IfrOptionList[Index].StringToken = NewMenuEntry->DisplayStringToken;\r
@@ -736,12 +741,15 @@ UpdateConModePage (
     if (EFI_ERROR (Status)) {\r
       continue;\r
     }\r
+    \r
     //\r
     // Build mode string Column x Row\r
     //\r
     UnicodeValueToString (ModeString, 0, Col, 0);\r
+    ASSERT ((StrLen (ModeString)  + 1) < (sizeof (ModeString) / sizeof (ModeString[0])));\r
     StrCat (ModeString, L" x ");\r
     UnicodeValueToString (RowString, 0, Row, 0);\r
+    ASSERT ((StrLen (ModeString)  + StrLen(RowString)) < (sizeof (ModeString) / sizeof (ModeString[0])));\r
     StrCat (ModeString, RowString);\r
 \r
     HiiLibNewString (CallbackData->BmmHiiHandle, &ModeToken[Index], ModeString);\r
@@ -1023,7 +1031,11 @@ GetLegacyBootOptionVar (
                   &gEfiGlobalVariableGuid,\r
                   &OrderSize\r
                   );\r
-\r
+                  \r
+  if (OrderBuffer == NULL) {\r
+    return NULL;\r
+  }\r
+  \r
   for (Index = 0; Index < OrderSize / sizeof (UINT16); Index++) {\r
     UnicodeSPrint (StrTemp, 100, L"Boot%04x", OrderBuffer[Index]);\r
     OptionBuffer = BdsLibGetVariableAndSize (\r
@@ -1177,6 +1189,9 @@ UpdateSetLegacyDeviceOrderPage (
     OldData     = CallbackData->BmmOldFakeNVData.LegacyBEV;\r
     break;\r
 \r
+  default:\r
+    DEBUG ((EFI_D_ERROR, "Invalid command ID for updating page!\n"));\r
+    return;\r
   }\r
 \r
   CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r