Update PeiCore and DxeCore to verify FFS data checksum.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11332 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2011-02-23 03:09:55 +00:00
parent 59424fff04
commit 89cd8129f7
2 changed files with 21 additions and 5 deletions

View File

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