summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-19 09:57:11 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-19 09:57:11 +0000
commit8c08a567c64814f36f7261ca5652ef0350ca660e (patch)
tree1e45b7030f67f917749dcc814c5a44621686059b /IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
parenta7450323c22532e9a19847b0bcfbcafdc7b067fb (diff)
downloadedk2-platforms-8c08a567c64814f36f7261ca5652ef0350ca660e.tar.xz
Add code to check boot option variable before use it
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13203 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c')
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index 6f06ac9a85..c9c694e648 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -1238,6 +1238,13 @@ BdsLibDeleteOptionFromHandle (
return EFI_OUT_OF_RESOURCES;
}
+ if (!ValidateOption(BootOptionVar, BootOptionSize)) {
+ BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);
+ FreePool (BootOptionVar);
+ Index++;
+ continue;
+ }
+
TempPtr = BootOptionVar;
TempPtr += sizeof (UINT32) + sizeof (UINT16);
TempPtr += StrSize ((CHAR16 *) TempPtr);
@@ -1300,10 +1307,14 @@ BdsDeleteAllInvalidEfiBootOption (
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath;
UINT8 *TempPtr;
CHAR16 *Description;
+ BOOLEAN Corrupted;
- Status = EFI_SUCCESS;
- BootOrder = NULL;
- BootOrderSize = 0;
+ Status = EFI_SUCCESS;
+ BootOrder = NULL;
+ Description = NULL;
+ OptionDevicePath = NULL;
+ BootOrderSize = 0;
+ Corrupted = FALSE;
//
// Check "BootOrder" variable firstly, this variable hold the number of boot options
@@ -1330,23 +1341,27 @@ BdsDeleteAllInvalidEfiBootOption (
return EFI_OUT_OF_RESOURCES;
}
- TempPtr = BootOptionVar;
- TempPtr += sizeof (UINT32) + sizeof (UINT16);
- Description = (CHAR16 *) TempPtr;
- TempPtr += StrSize ((CHAR16 *) TempPtr);
- OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
+ if (!ValidateOption(BootOptionVar, BootOptionSize)) {
+ Corrupted = TRUE;
+ } else {
+ TempPtr = BootOptionVar;
+ TempPtr += sizeof (UINT32) + sizeof (UINT16);
+ Description = (CHAR16 *) TempPtr;
+ TempPtr += StrSize ((CHAR16 *) TempPtr);
+ OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
- //
- // Skip legacy boot option (BBS boot device)
- //
- if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&
- (DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {
- FreePool (BootOptionVar);
- Index++;
- continue;
+ //
+ // Skip legacy boot option (BBS boot device)
+ //
+ if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&
+ (DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {
+ FreePool (BootOptionVar);
+ Index++;
+ continue;
+ }
}
- if (!BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {
+ if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {
//
// Delete this invalid boot option "Boot####"
//
@@ -1361,6 +1376,7 @@ BdsDeleteAllInvalidEfiBootOption (
// Mark this boot option in boot order as deleted
//
BootOrder[Index] = 0xffff;
+ Corrupted = FALSE;
}
FreePool (BootOptionVar);