FIT checksum bugfix

- and small refactorings
This commit is contained in:
Nikolaj Schlej 2016-07-18 06:49:31 +02:00
parent f90427229d
commit 03567dbe66
3 changed files with 13 additions and 14 deletions

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
std::vector<std::vector<QString> > 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() << " | "

View File

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

View File

@ -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");
}
}