mirror of https://github.com/acidanthera/audk.git
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:
parent
59424fff04
commit
89cd8129f7
|
@ -217,6 +217,8 @@ IsValidFfsFile (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_FFS_FILE_STATE FileState;
|
EFI_FFS_FILE_STATE FileState;
|
||||||
|
UINT8 DataCheckSum;
|
||||||
|
UINT32 FileLength;
|
||||||
|
|
||||||
FileState = GetFileState (ErasePolarity, FfsHeader);
|
FileState = GetFileState (ErasePolarity, FfsHeader);
|
||||||
switch (FileState) {
|
switch (FileState) {
|
||||||
|
@ -224,11 +226,14 @@ IsValidFfsFile (
|
||||||
case EFI_FILE_DELETED:
|
case EFI_FILE_DELETED:
|
||||||
case EFI_FILE_DATA_VALID:
|
case EFI_FILE_DATA_VALID:
|
||||||
case EFI_FILE_MARKED_FOR_UPDATE:
|
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||||
//
|
DataCheckSum = FFS_FIXED_CHECKSUM;
|
||||||
// Some other vliadation like file content checksum might be done here.
|
FileLength = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
|
||||||
// For performance issue, Tiano only do FileState check.
|
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));
|
||||||
return TRUE;
|
}
|
||||||
|
if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -162,6 +162,7 @@ FindFileEx (
|
||||||
UINT64 FvLength;
|
UINT64 FvLength;
|
||||||
UINT8 ErasePolarity;
|
UINT8 ErasePolarity;
|
||||||
UINT8 FileState;
|
UINT8 FileState;
|
||||||
|
UINT8 DataCheckSum;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert the handle of FV to FV header for memory-mapped firmware volume
|
// Convert the handle of FV to FV header for memory-mapped firmware volume
|
||||||
|
@ -219,6 +220,16 @@ FindFileEx (
|
||||||
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||||
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
|
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 (FileName != NULL) {
|
||||||
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
|
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
|
||||||
*FileHeader = FfsFileHeader;
|
*FileHeader = FfsFileHeader;
|
||||||
|
|
Loading…
Reference in New Issue