This commit is contained in:
Alex Matrosov 2018-01-22 23:58:29 -08:00
parent 3ffdae1123
commit 9d623c91e6
2 changed files with 15 additions and 12 deletions

View File

@ -871,9 +871,8 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
if (msgUnknownRevision) if (msgUnknownRevision)
msg(tr("parseBios: unknown volume revision %1").arg(volumeHeader->Revision), index); msg(tr("parseBios: unknown volume revision %1").arg(volumeHeader->Revision), index);
if (msgSizeMismach) if (msgSizeMismach)
msg(tr("parseBios: volume size stored in header %1h (%2) differs from calculated using block map %3h (%4)") msg(tr("parseBios: volume size stored in header %1h differs from calculated using block map %3h")
.hexarg(volumeSize).arg(volumeSize) .hexarg(volumeSize).arg(bmVolumeSize),
.hexarg(bmVolumeSize).arg(bmVolumeSize),
index); index);
// Go to next volume // Go to next volume
@ -1219,16 +1218,16 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
// Construct empty byte for this file // Construct empty byte for this file
char empty = erasePolarity ? '\xFF' : '\x00'; char empty = erasePolarity ? '\xFF' : '\x00';
// Get file header // Get file header
QByteArray header = file.left(sizeof(EFI_FFS_FILE_HEADER)); QByteArray header = file.left(sizeof(EFI_FFS_FILE_HEADER));
if (revision > 1 && (fileHeader->Attributes & FFS_ATTRIB_LARGE_FILE)) { if (revision > 1 && (fileHeader->Attributes & FFS_ATTRIB_LARGE_FILE)) {
if ((UINT32)file.size() < sizeof(EFI_FFS_FILE_HEADER2)) if ((UINT32)file.size() < sizeof(EFI_FFS_FILE_HEADER2))
return ERR_INVALID_FILE; return ERR_INVALID_FILE;
header = file.left(sizeof(EFI_FFS_FILE_HEADER2)); header = file.left(sizeof(EFI_FFS_FILE_HEADER2));
} }
// Check header checksum // Check header checksum
UINT8 calculatedHeader = 0x100 -(calculateSum8((const UINT8*)header.constData(), header.size()) - fileHeader->IntegrityCheck.Checksum.Header - fileHeader->IntegrityCheck.Checksum.File - fileHeader->State); UINT8 calculatedHeader = 0x100 - (calculateSum8((const UINT8*)header.constData(), header.size()) - fileHeader->IntegrityCheck.Checksum.Header - fileHeader->IntegrityCheck.Checksum.File - fileHeader->State);
if (fileHeader->IntegrityCheck.Checksum.Header != calculatedHeader) if (fileHeader->IntegrityCheck.Checksum.Header != calculatedHeader)
msgInvalidHeaderChecksum = true; msgInvalidHeaderChecksum = true;
@ -1253,12 +1252,16 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
UINT8 calculatedData = 0; UINT8 calculatedData = 0;
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM) { if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {
calculatedData = calculateChecksum8((const UINT8*)body.constData(), body.size()); calculatedData = calculateChecksum8((const UINT8*)body.constData(), body.size());
if (fileHeader->IntegrityCheck.Checksum.File != calculatedData)
msgInvalidDataChecksum = true;
} }
// Data checksum must be one of predefined values // Data checksum must be one of predefined values
else if ((revision == 1 && fileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) else if (revision == 1) {
|| fileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM2) calculatedData = FFS_FIXED_CHECKSUM;
}
else {
calculatedData = FFS_FIXED_CHECKSUM2;
}
if (fileHeader->IntegrityCheck.Checksum.File != calculatedData)
msgInvalidDataChecksum = true; msgInvalidDataChecksum = true;
// Parse current file by default // Parse current file by default

View File

@ -17,7 +17,7 @@
UEFITool::UEFITool(QWidget *parent) : UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::UEFITool), ui(new Ui::UEFITool),
version(tr("0.22.1")) version(tr("0.22.2"))
{ {
clipboard = QApplication::clipboard(); clipboard = QApplication::clipboard();