From 47d988387efc8b45561f542f7a8e5b6a43979a8c Mon Sep 17 00:00:00 2001 From: Min M Xu Date: Sun, 27 Nov 2022 15:00:14 +0800 Subject: [PATCH] OvmfPkg/PlatformInitLib: Add check to NvVarStoreFV HeaderLength There should be a check that the FV HeaderLength cannot be an odd number. Otherwise in the following CalculateSum16 there would be an ASSERT. In ValidateFvHeader@QemuFlashFvbServicesRuntimeDxe/FwBlockServices.c there a is similar check to the FwVolHeader->HeaderLength. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Signed-off-by: Min Xu Reviewed-by: Jiewen Yao --- OvmfPkg/Library/PlatformInitLib/Platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/PlatformInitLib/Platform.c index 2582689ffe..77f22de046 100644 --- a/OvmfPkg/Library/PlatformInitLib/Platform.c +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c @@ -653,6 +653,7 @@ PlatformValidateNvVarStore ( (!CompareGuid (&FvHdrGUID, &NvVarStoreFvHeader->FileSystemGuid)) || (NvVarStoreFvHeader->Signature != EFI_FVH_SIGNATURE) || (NvVarStoreFvHeader->Attributes != 0x4feff) || + ((NvVarStoreFvHeader->HeaderLength & 0x01) != 0) || (NvVarStoreFvHeader->Revision != EFI_FVH_REVISION) || (NvVarStoreFvHeader->FvLength != NvVarStoreSize) )