Fix CPD Extension offset (reverts 29915ca)

The CPD Extensions should have the header size added as an
offset instead.
This commit is contained in:
Kamay Xutax 2023-08-19 22:25:38 +02:00 committed by Nikolaj Schlej
parent 29915ca620
commit 4992474e83
2 changed files with 12 additions and 9 deletions

View file

@ -4673,10 +4673,13 @@ make_partition_table_consistent:
manifestHeader->ExponentSize * (UINT32)sizeof(UINT32), manifestHeader->ExponentSize * (UINT32)sizeof(UINT32));
// Add tree item
UModelIndex partitionIndex = model->addItem(localOffset + header.size() + partitions[i].ptEntry.Offset.Offset, Types::CpdPartition, Subtypes::ManifestCpdPartition, name, UString(), info, header, body, UByteArray(), Fixed, parent);
UModelIndex partitionIndex = model->addItem(localOffset + partitions[i].ptEntry.Offset.Offset, Types::CpdPartition, Subtypes::ManifestCpdPartition, name, UString(), info, header, body, UByteArray(), Fixed, parent);
// Parse data as extensions area
parseCpdExtensionsArea(partitionIndex);
// Add the header size as a local offset
// Since the body starts after the
// header length
parseCpdExtensionsArea(partitionIndex, header.size());
}
}
}
@ -4695,7 +4698,7 @@ make_partition_table_consistent:
UModelIndex partitionIndex = model->addItem(localOffset + partitions[i].ptEntry.Offset.Offset, Types::CpdPartition, Subtypes::MetadataCpdPartition, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
// Parse data as extensions area
parseCpdExtensionsArea(partitionIndex);
parseCpdExtensionsArea(partitionIndex, 0);
}
// It's a code
else {
@ -4731,7 +4734,7 @@ make_partition_table_consistent:
return U_SUCCESS;
}
USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index)
USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index, const UINT32 localOffset)
{
if (!index.isValid()) {
return U_INVALID_PARAMETER;
@ -4772,7 +4775,7 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index)
infoHeader->UsageBitmap[12], infoHeader->UsageBitmap[13], infoHeader->UsageBitmap[14], infoHeader->UsageBitmap[15]);
// Add tree item
extIndex = model->addItem(offset, Types::CpdExtension, 0, name, UString(), info, header, data, UByteArray(), Fixed, index);
extIndex = model->addItem(offset + localOffset, Types::CpdExtension, 0, name, UString(), info, header, data, UByteArray(), Fixed, index);
parseSignedPackageInfoData(extIndex);
}
// Parse IFWI Partition Manifest a bit further
@ -4815,7 +4818,7 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index)
+ UString("\nPartition hash: ") + UString(hash.toHex().constData());
// Add tree item
extIndex = model->addItem(offset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
extIndex = model->addItem(offset + localOffset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
if (msgHashSizeMismatch) {
msg(usprintf("%s: IFWI Partition Manifest hash size is %u, maximum allowed is %u, truncated", __FUNCTION__, attrHeader->HashSize, (UINT32)sizeof(attrHeader->CompletePartitionHash)), extIndex);
}
@ -4840,12 +4843,12 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index)
attrHeader->GlobalModuleId) + UString(hash.toHex().constData());
// Add tree item
extIndex = model->addItem(offset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
extIndex = model->addItem(offset + localOffset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
}
// Parse everything else
else {
// Add tree item, if needed
extIndex = model->addItem(offset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
extIndex = model->addItem(offset + localOffset, Types::CpdExtension, 0, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, index);
}
// There needs to be a more generic way to do it, but it is fine for now

View file

@ -130,7 +130,7 @@ private:
USTATUS parseBpdtRegion(const UByteArray & region, const UINT32 localOffset, const UINT32 sbpdtOffsetFixup, const UModelIndex & parent, UModelIndex & index);
USTATUS parseCpdRegion(const UByteArray & region, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseCpdExtensionsArea(const UModelIndex & index);
USTATUS parseCpdExtensionsArea(const UModelIndex & index, const UINT32 localOffset);
USTATUS parseSignedPackageInfoData(const UModelIndex & index);
USTATUS parseRawArea(const UModelIndex & index);