From 03567dbe662c692c7432c5b44997a20652ed1c6e Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Mon, 18 Jul 2016 06:49:31 +0200 Subject: [PATCH] FIT checksum bugfix - and small refactorings --- UEFIExtract/uefiextract_main.cpp | 2 +- common/ffsparser.cpp | 5 ++--- common/types.cpp | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/UEFIExtract/uefiextract_main.cpp b/UEFIExtract/uefiextract_main.cpp index ccf7d33..1263ff7 100644 --- a/UEFIExtract/uefiextract_main.cpp +++ b/UEFIExtract/uefiextract_main.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) std::vector > fitTable = ffsParser.getFitTable(); if (fitTable.size()) { std::cout << "-------------------------------------------------------------------" << std::endl; - std::cout << " Address | Size | Ver | CS | Type " << std::endl; + std::cout << " Address | Size | Ver | CS | Type " << std::endl; std::cout << "-------------------------------------------------------------------" << std::endl; for (size_t i = 0; i < fitTable.size(); i++) { std::cout << fitTable[i][0].toLatin1().constData() << " | " diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 7d9939f..a0a999c 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -2896,16 +2896,15 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff) FIT_ENTRY* tempFitHeader = (FIT_ENTRY*)tempFIT.data(); tempFitHeader->Checksum = 0; UINT8 calculated = calculateChecksum8((const UINT8*)tempFitHeader, fitSize); - calculated |= 0x80; // Set checksum flag on calculated checksum if (calculated != fitHeader->Checksum) { msg(usprintf("parseFit: invalid FIT table checksum %02Xh, should be %02Xh", fitHeader->Checksum, calculated), fitIndex); } } // Check fit header type - if ((fitHeader->Type & 0x7F) != FIT_TYPE_HEADER) { + if ((fitHeader->Type & 0x7F) != FIT_TYPE_HEADER) msg(("Invalid FIT header type"), fitIndex); - } + // Add FIT header to fitTable std::vector currentStrings; diff --git a/common/types.cpp b/common/types.cpp index 4a3a4d9..4f503d7 100644 --- a/common/types.cpp +++ b/common/types.cpp @@ -167,16 +167,16 @@ UString actionTypeToUString(const UINT8 action) UString fitEntryTypeToUString(const UINT8 type) { switch (type & 0x7F) { - case FIT_TYPE_HEADER: return ("FIT Header "); - case FIT_TYPE_MICROCODE: return ("Microcode "); - case FIT_TYPE_BIOS_AC_MODULE: return ("BIOS ACM "); - case FIT_TYPE_BIOS_INIT_MODULE: return ("BIOS Init "); - case FIT_TYPE_TPM_POLICY: return ("TPM Policy "); - case FIT_TYPE_BIOS_POLICY_DATA: return ("BIOS Policy Data "); + case FIT_TYPE_HEADER: return ("FIT Header"); + case FIT_TYPE_MICROCODE: return ("Microcode"); + case FIT_TYPE_BIOS_AC_MODULE: return ("BIOS ACM"); + case FIT_TYPE_BIOS_INIT_MODULE: return ("BIOS Init"); + case FIT_TYPE_TPM_POLICY: return ("TPM Policy"); + case FIT_TYPE_BIOS_POLICY_DATA: return ("BIOS Policy Data"); case FIT_TYPE_TXT_CONF_POLICY: return ("TXT Configuration Policy"); - case FIT_TYPE_AC_KEY_MANIFEST: return ("BootGuard Key Manifest "); - case FIT_TYPE_AC_BOOT_POLICY: return ("BootGuard Boot Policy "); - case FIT_TYPE_EMPTY: return ("Empty "); - default: return ("Unknown "); + case FIT_TYPE_AC_KEY_MANIFEST: return ("BootGuard Key Manifest"); + case FIT_TYPE_AC_BOOT_POLICY: return ("BootGuard Boot Policy"); + case FIT_TYPE_EMPTY: return ("Empty"); + default: return ("Unknown"); } } \ No newline at end of file