From: klu2 Date: Mon, 25 Jan 2010 09:56:20 +0000 (+0000) Subject: Fix the issue that accessing for unaligned address break IPF X-Git-Tag: edk2-stable201903~16524 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b4d856a6b52a724e7cf04653f3049a47641a9f39 Fix the issue that accessing for unaligned address break IPF git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9809 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index cab1cdb001..d2bd6c493e 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -853,6 +853,7 @@ ProcessFvFile ( EFI_PEI_FV_HANDLE ParentFvHandle; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FV_FILE_INFO FileInfo; + UINT64 FvLength; // // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already @@ -890,7 +891,7 @@ ProcessFvFile ( // // FvAlignment must be more than 8 bytes required by FvHeader structure. // - FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16); + FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16); if (FvAlignment < 8) { FvAlignment = 8; } @@ -899,11 +900,12 @@ ProcessFvFile ( // Check FvImage // if ((UINTN) FvHeader % FvAlignment != 0) { - NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvHeader->FvLength), FvAlignment); + FvLength = ReadUnaligned64 (&FvHeader->FvLength); + NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment); if (NewFvBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } - CopyMem (NewFvBuffer, FvHeader, (UINTN) FvHeader->FvLength); + CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength); FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer; }