diff options
Diffstat (limited to 'IntelFrameworkModulePkg/Universal/BdsDxe')
4 files changed, 32 insertions, 36 deletions
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c index 7d9d47cd5d..d5674e3b42 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c @@ -702,19 +702,17 @@ ApplyChangeHandler ( break;
case FORM_CON_IN_ID:
- for (Index = 0;
- ((Index < ConsoleInpMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
- Index++) {
+ for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
}
- for (Index = 0;
- ((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleInpMenu.MenuNumber)));
- Index++) {
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];
}
@@ -722,19 +720,17 @@ ApplyChangeHandler ( break;
case FORM_CON_OUT_ID:
- for (Index = 0;
- ((Index < ConsoleOutMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
- Index++) {
+ for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
}
- for (Index = 0;
- ((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleOutMenu.MenuNumber)));
- Index++) {
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConOut = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];
}
@@ -742,20 +738,17 @@ ApplyChangeHandler ( break;
case FORM_CON_ERR_ID:
- ASSERT ((ConsoleErrMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8)));
- for (Index = 0;
- ((Index < ConsoleErrMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
- Index++) {
+ for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
}
- for (Index = 0;
- ((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleErrMenu.MenuNumber)));
- Index++) {
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsStdErr = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];
}
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h index e67ae2c628..f177e75f5e 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h @@ -86,6 +86,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // End Label
//
#define LABEL_END 0xffff
+#define MAX_MENU_NUMBER 100
///
/// This is the structure that will be used to store the
@@ -124,8 +125,8 @@ typedef struct { //
// Driver Option Add Handle page storage
//
- UINT16 DriverAddHandleDesc[100];
- UINT16 DriverAddHandleOptionalData[100];
+ UINT16 DriverAddHandleDesc[MAX_MENU_NUMBER];
+ UINT16 DriverAddHandleOptionalData[MAX_MENU_NUMBER];
UINT8 DriverAddActive;
UINT8 DriverAddForceReconnect;
@@ -142,19 +143,19 @@ typedef struct { //
// At most 100 input/output/errorout device for console storage
//
- UINT8 ConsoleCheck[100];
+ UINT8 ConsoleCheck[MAX_MENU_NUMBER];
//
// Boot or Driver Option Order storage
//
- UINT8 OptionOrder[100];
- UINT8 DriverOptionToBeDeleted[100];
+ UINT8 OptionOrder[MAX_MENU_NUMBER];
+ UINT8 DriverOptionToBeDeleted[MAX_MENU_NUMBER];
//
// Boot Option Delete storage
//
- UINT8 BootOptionDel[100];
- UINT8 DriverOptionDel[100];
+ UINT8 BootOptionDel[MAX_MENU_NUMBER];
+ UINT8 DriverOptionDel[MAX_MENU_NUMBER];
//
// This is the Terminal Attributes value storage
@@ -168,11 +169,11 @@ typedef struct { //
// Legacy Device Order Selection Storage
//
- UINT8 LegacyFD[100];
- UINT8 LegacyHD[100];
- UINT8 LegacyCD[100];
- UINT8 LegacyNET[100];
- UINT8 LegacyBEV[100];
+ UINT8 LegacyFD[MAX_MENU_NUMBER];
+ UINT8 LegacyHD[MAX_MENU_NUMBER];
+ UINT8 LegacyCD[MAX_MENU_NUMBER];
+ UINT8 LegacyNET[MAX_MENU_NUMBER];
+ UINT8 LegacyBEV[MAX_MENU_NUMBER];
//
// We use DisableMap array to record the enable/disable state of each boot device
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c index 643c90d4b1..2334fd61b6 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c @@ -490,6 +490,7 @@ UpdateConsolePage ( NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||
((NewTerminalContext->IsConOut != 0) && (UpdatePageId == FORM_CON_OUT_ID)) ||
((NewTerminalContext->IsStdErr != 0) && (UpdatePageId == FORM_CON_ERR_ID))
@@ -755,6 +756,7 @@ UpdateConModePage ( UINTN Row;
CHAR16 RowString[50];
CHAR16 ModeString[50];
+ CHAR16 *pStr;
UINTN TempStringLen;
UINTN MaxMode;
UINTN ValidMode;
@@ -811,11 +813,11 @@ UpdateConModePage ( // Build mode string Column x Row
//
TempStringLen = UnicodeValueToString (ModeString, 0, Col, 0);
- ASSERT ((TempStringLen + StrLen (L" x ")) < (sizeof (ModeString) / sizeof (ModeString[0])));
- StrCat (ModeString, L" x ");
+ pStr = &ModeString[0];
+ StrnCat (pStr, L" x ", StrLen(L" x "));
TempStringLen = UnicodeValueToString (RowString, 0, Row, 0);
- ASSERT ((StrLen (ModeString) + TempStringLen) < (sizeof (ModeString) / sizeof (ModeString[0])));
- StrCat (ModeString, RowString);
+ pStr = &ModeString[0];
+ StrnCat (pStr, RowString, StrLen(RowString));
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index eda86fdcba..80af8e1803 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c @@ -273,7 +273,6 @@ CallBootManager ( if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) {
BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1;
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY));
-
} else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) {
BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1;
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD));
@@ -299,6 +298,7 @@ CallBootManager ( Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK));
}
+ ASSERT (Option->Description != NULL);
if (StrnCmp (BootStringNumber, L"0", 1) != 0) {
StrCat (Option->Description, L" ");
StrCat (Option->Description, BootStringNumber);
|