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 <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Min M Xu 2022-11-27 15:00:14 +08:00 committed by mergify[bot]
parent a1d5723914
commit 47d988387e
1 changed files with 1 additions and 0 deletions

View File

@ -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)
)