Revision: 18215
http://sourceforge.net/p/edk2/code/18215
Author: dandanbi
Date: 2015-08-13 00:56:09 +0000 (Thu, 13 Aug 2015)
Log Message:
-----------
IntelFrameworkModulePkg:Refine the code in LegacyBootMaintUiLib
Refine the code in LegacyBootMaintUiLib to prevent the potential risk.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>
Reviewed-by: Eric Dong <[email protected]>
Modified Paths:
--------------
trunk/edk2/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
Modified:
trunk/edk2/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
===================================================================
---
trunk/edk2/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
2015-08-13 00:15:06 UTC (rev 18214)
+++
trunk/edk2/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
2015-08-13 00:56:09 UTC (rev 18215)
@@ -144,6 +144,8 @@
*EnBootOptionCount = 0;
Index = 0;
+ ASSERT (BbsIndexArray != NULL);
+ ASSERT (DeviceTypeArray != NULL);
ASSERT (*EnBootOption != NULL);
ASSERT (*DisBootOption != NULL);
@@ -175,6 +177,7 @@
//
StartPosition = BootOrderSize / sizeof (UINT16);
NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));
+ ASSERT (NewBootOption != NULL);
while (DevOrderCount-- != 0) {
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {
@@ -1178,6 +1181,7 @@
UINTN Pos;
UINTN Bit;
UINT8 *DisMap;
+ UINTN TotalLength;
LegacyDev = NULL;
OptionMenu = NULL;
@@ -1228,9 +1232,10 @@
//
// Create oneof tag here for FD/HD/CD #1 #2
//
- for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {
- VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + sizeof (BBS_TYPE) +
sizeof (UINT16) + Index * sizeof (UINT16));
-
+ for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {
+ TotalLength = sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof
(UINT16);
+ VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + TotalLength);
+
if (0xFF00 == (VarDevOrder & 0xFF00)) {
LegacyDev[Index] = 0xFF;
Pos = (VarDevOrder & 0xFF) / 8;
@@ -1241,7 +1246,7 @@
}
}
- VarData += sizeof (BBS_TYPE);
+ VarData ++;
VarData += *(UINT16 *) VarData;
DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;
}
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits