Version 0.17.7

- corrected possible bug with extended volume header handling in growVolume routine
This commit is contained in:
Nikolaj Schlej 2014-04-14 14:10:08 +02:00
parent a9d03436a4
commit 706b0088e3
4 changed files with 15 additions and 9 deletions

View File

@ -82,6 +82,7 @@ typedef uint16_t CHAR16;
#define ERR_GENERIC_CALL_NOT_SUPPORTED 32 #define ERR_GENERIC_CALL_NOT_SUPPORTED 32
#define ERR_VOLUME_BASE_NOT_FOUND 33 #define ERR_VOLUME_BASE_NOT_FOUND 33
#define ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND 34 #define ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND 34
#define ERR_COMPLEX_BLOCK_MAP 35
#define ERR_NOT_IMPLEMENTED 0xFF #define ERR_NOT_IMPLEMENTED 0xFF
// Compression algorithms // Compression algorithms

View File

@ -40,7 +40,7 @@ TreeModel* FfsEngine::treeModel() const
return model; return model;
} }
void FfsEngine::msg(const QString & message, const QModelIndex index) void FfsEngine::msg(const QString & message, const QModelIndex & index)
{ {
messageItems.enqueue(MessageListItem(message, NULL, 0, index)); messageItems.enqueue(MessageListItem(message, NULL, 0, index));
} }
@ -1848,7 +1848,7 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
} }
// Construction routines // Construction routines
UINT8 FfsEngine::constructPadFile(const QByteArray guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad) UINT8 FfsEngine::constructPadFile(const QByteArray &guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad)
{ {
if (size < sizeof(EFI_FFS_FILE_HEADER) || erasePolarity == ERASE_POLARITY_UNKNOWN) if (size < sizeof(EFI_FFS_FILE_HEADER) || erasePolarity == ERASE_POLARITY_UNKNOWN)
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
@ -2690,8 +2690,7 @@ UINT8 FfsEngine::growVolume(QByteArray & header, const UINT32 size, UINT32 & new
EFI_FV_BLOCK_MAP_ENTRY* blockMap = (EFI_FV_BLOCK_MAP_ENTRY*) (header.data() + sizeof(EFI_FIRMWARE_VOLUME_HEADER)); EFI_FV_BLOCK_MAP_ENTRY* blockMap = (EFI_FV_BLOCK_MAP_ENTRY*) (header.data() + sizeof(EFI_FIRMWARE_VOLUME_HEADER));
// Get block map size // Get block map size
UINT32 extHeaderOffset = volumeHeader->Revision == 2 ? volumeHeader->ExtHeaderOffset : 0; UINT32 blockMapSize = volumeHeader->HeaderLength - sizeof(EFI_FIRMWARE_VOLUME_HEADER);
UINT32 blockMapSize = header.size() - extHeaderOffset - sizeof(EFI_FIRMWARE_VOLUME_HEADER);
if (blockMapSize % sizeof(EFI_FV_BLOCK_MAP_ENTRY)) if (blockMapSize % sizeof(EFI_FV_BLOCK_MAP_ENTRY))
return ERR_INVALID_VOLUME; return ERR_INVALID_VOLUME;
UINT32 blockMapCount = blockMapSize / sizeof(EFI_FV_BLOCK_MAP_ENTRY); UINT32 blockMapCount = blockMapSize / sizeof(EFI_FV_BLOCK_MAP_ENTRY);
@ -2700,13 +2699,19 @@ UINT8 FfsEngine::growVolume(QByteArray & header, const UINT32 size, UINT32 & new
if (blockMap[blockMapCount-1].NumBlocks != 0 || blockMap[blockMapCount-1].Length != 0) if (blockMap[blockMapCount-1].NumBlocks != 0 || blockMap[blockMapCount-1].Length != 0)
return ERR_INVALID_VOLUME; return ERR_INVALID_VOLUME;
// Case of complex blockMap
//!TODO: implement this case
if (blockMapCount > 2)
return ERR_COMPLEX_BLOCK_MAP;
// Calculate new size // Calculate new size
if (newSize <= size) if (newSize <= size)
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
newSize += blockMap->Length - newSize % blockMap->Length;
newSize += blockMap[0].Length - newSize % blockMap[0].Length;
// Recalculate number of blocks // Recalculate number of blocks
blockMap->NumBlocks = newSize / blockMap->Length; blockMap[0].NumBlocks = newSize / blockMap[0].Length;
// Set new volume size // Set new volume size
volumeHeader->FvLength = 0; volumeHeader->FvLength = 0;

View File

@ -98,7 +98,7 @@ private:
UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize); UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize);
// Reconstruction helpers // Reconstruction helpers
UINT8 constructPadFile(const QByteArray guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad); UINT8 constructPadFile(const QByteArray &guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad);
UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize); UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize);
// Rebase routines // Rebase routines
@ -112,7 +112,7 @@ private:
// Message helper // Message helper
QQueue<MessageListItem> messageItems; QQueue<MessageListItem> messageItems;
void msg(const QString & message, const QModelIndex index = QModelIndex()); void msg(const QString & message, const QModelIndex &index = QModelIndex());
// Internal operations // Internal operations
bool hasIntersection(const UINT32 begin1, const UINT32 end1, const UINT32 begin2, const UINT32 end2); bool hasIntersection(const UINT32 begin1, const UINT32 end1, const UINT32 begin2, const UINT32 end2);

View File

@ -20,7 +20,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>UEFITool 0.17.6</string> <string>UEFITool 0.17.7</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<property name="sizePolicy"> <property name="sizePolicy">