summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Core/Dxe/FwVol/Ffs.c15
-rw-r--r--MdeModulePkg/Core/Pei/FwVol/FwVol.c11
2 files changed, 21 insertions, 5 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
index aec08b2..5eb22d0 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
@@ -217,6 +217,8 @@ IsValidFfsFile (
)
{
EFI_FFS_FILE_STATE FileState;
+ UINT8 DataCheckSum;
+ UINT32 FileLength;
FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) {
@@ -224,11 +226,14 @@ IsValidFfsFile (
case EFI_FILE_DELETED:
case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE:
- //
- // Some other vliadation like file content checksum might be done here.
- // For performance issue, Tiano only do FileState check.
- //
- return TRUE;
+ DataCheckSum = FFS_FIXED_CHECKSUM;
+ FileLength = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
+ if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsHeader + sizeof(EFI_FFS_FILE_HEADER), FileLength - sizeof(EFI_FFS_FILE_HEADER));
+ }
+ if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
+ return TRUE;
+ }
default:
return FALSE;
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index c40f0ea..941657c 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -162,6 +162,7 @@ FindFileEx (
UINT64 FvLength;
UINT8 ErasePolarity;
UINT8 FileState;
+ UINT8 DataCheckSum;
//
// Convert the handle of FV to FV header for memory-mapped firmware volume
@@ -219,6 +220,16 @@ FindFileEx (
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
+ DataCheckSum = FFS_FIXED_CHECKSUM;
+ if ((FfsFileHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER), FileLength - sizeof(EFI_FFS_FILE_HEADER));
+ }
+ if (FfsFileHeader->IntegrityCheck.Checksum.File != DataCheckSum) {
+ ASSERT (FALSE);
+ *FileHeader = NULL;
+ return EFI_NOT_FOUND;
+ }
+
if (FileName != NULL) {
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
*FileHeader = FfsFileHeader;