UEFITool 0.19.2

- correct a bug with legacy EFI1.1/Tiano compression routines, which lead to possible image corruption
This commit is contained in:
Nikolaj Schlej 2014-11-10 17:48:59 +01:00
parent b9f4142aac
commit d89aac244c
6 changed files with 3364 additions and 1608 deletions

File diff suppressed because it is too large Load Diff

View File

@ -55,15 +55,23 @@ extern "C" {
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/
UINT8
EFI_STATUS
TianoCompress(
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
UINT32 SrcSize,
VOID *DstBuffer,
UINT64 *DstSize
UINT32 *DstSize
)
;
EFI_STATUS
TianoCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
/*++
Routine Description:
@ -87,12 +95,20 @@ extern "C" {
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/
UINT8
EFI_STATUS
EfiCompress(
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
UINT32 SrcSize,
VOID *DstBuffer,
UINT64 *DstSize
UINT32 *DstSize
)
;
EFI_STATUS
EfiCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;

File diff suppressed because it is too large Load Diff

View File

@ -895,7 +895,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
.arg(volumeHeader->Revision)
.hexarg(volumeHeader->Attributes, 8)
.arg(empty ? "1" : "0")
.hexarg(headerSize, 4);
.hexarg(headerSize, 8);
// Extended header present
if (volumeHeader->Revision > 1 && volumeHeader->ExtHeaderOffset) {
EFI_FIRMWARE_VOLUME_EXT_HEADER* extendedHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(volume.constData() + volumeHeader->ExtHeaderOffset);
@ -2242,7 +2242,28 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
break;
case COMPRESSION_ALGORITHM_EFI11:
{
UINT64 compressedSize = 0;
// Try legacy function first
UINT32 compressedSize = 0;
if (EfiCompressLegacy(data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize];
if (EfiCompressLegacy(data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS) {
delete[] compressed;
return ERR_STANDARD_COMPRESSION_FAILED;
}
compressedData = QByteArray((const char*)compressed, compressedSize);
// Check that compressed data can be decompressed normally
QByteArray decompressed;
if (decompress(compressedData, EFI_STANDARD_COMPRESSION, decompressed, NULL) == ERR_SUCCESS
&& decompressed == data) {
delete[] compressed;
return ERR_SUCCESS;
}
delete[] compressed;
// Legacy function failed, use current one
compressedSize = 0;
if (EfiCompress(data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize];
@ -2251,13 +2272,36 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
return ERR_STANDARD_COMPRESSION_FAILED;
}
compressedData = QByteArray((const char*)compressed, compressedSize);
// New functions will be trusted here, because another check will reduce performance
delete[] compressed;
return ERR_SUCCESS;
}
break;
case COMPRESSION_ALGORITHM_TIANO:
{
UINT64 compressedSize = 0;
// Try legacy function first
UINT32 compressedSize = 0;
if (TianoCompressLegacy(data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize];
if (TianoCompressLegacy(data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS) {
delete[] compressed;
return ERR_STANDARD_COMPRESSION_FAILED;
}
compressedData = QByteArray((const char*)compressed, compressedSize);
// Check that compressed data can be decompressed normally
QByteArray decompressed;
if (decompress(compressedData, EFI_STANDARD_COMPRESSION, decompressed, NULL) == ERR_SUCCESS
&& decompressed == data) {
delete[] compressed;
return ERR_SUCCESS;
}
delete[] compressed;
// Legacy function failed, use current one
compressedSize = 0;
if (TianoCompress(data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize];
@ -2266,6 +2310,8 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
return ERR_STANDARD_COMPRESSION_FAILED;
}
compressedData = QByteArray((const char*)compressed, compressedSize);
// New functions will be trusted here, because another check will reduce performance
delete[] compressed;
return ERR_SUCCESS;
}

View File

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

View File

@ -21,7 +21,8 @@ SOURCES += uefitool_main.cpp \
LZMA/SDK/C/LzmaDec.c \
LZMA/SDK/C/LzmaEnc.c \
Tiano/EfiTianoDecompress.c \
Tiano/EfiTianoCompress.c
Tiano/EfiTianoCompress.c \
Tiano/EfiTianoCompressLegacy.c
HEADERS += uefitool.h \
searchdialog.h \