diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h index 34e217707e71..b53eeb562253 100644 --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h @@ -813,4 +813,21 @@ EfiBootManagerDispatchDeferredImages ( VOID ); +/** + Validate the Boot####, Driver####, SysPrep#### and PlatformRecovery#### + variable (VendorGuid/Name) + + @param Variable The variable data. + @param VariableSize The variable size. + + @retval TRUE The variable data is correct. + @retval FALSE The variable data is corrupted. + +**/ +BOOLEAN +BmValidateOption ( + UINT8 *Variable, + UINTN VariableSize + ); + #endif diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c index e22aaf3039f1..2bfc5bd8b972 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c @@ -356,6 +356,11 @@ BOpt_GetBootOptions ( continue; } + if (!BmValidateOption (LoadOptionFromVar, BootOptionSize)) { + FreePool (LoadOptionFromVar); + continue; + } + if (BootNext != NULL) { BootNextFlag = (BOOLEAN)(*BootNext == BootOrderList[Index]); } else {