mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Fix nextBlockPosition calculation to prevent overwriting DDT and reset offsets
This commit is contained in:
@@ -1030,6 +1030,8 @@ void set_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sectorAddress, bool
|
|||||||
// Update nextBlockPosition to ensure future blocks don't overwrite the DDT
|
// Update nextBlockPosition to ensure future blocks don't overwrite the DDT
|
||||||
uint64_t ddtTotalSize = sizeof(DdtHeader2) + ddtHeader.length;
|
uint64_t ddtTotalSize = sizeof(DdtHeader2) + ddtHeader.length;
|
||||||
ctx->nextBlockPosition = (endOfFile + ddtTotalSize + alignmentMask) & ~alignmentMask;
|
ctx->nextBlockPosition = (endOfFile + ddtTotalSize + alignmentMask) & ~alignmentMask;
|
||||||
|
blockOffset = ctx->nextBlockPosition;
|
||||||
|
offset = 0;
|
||||||
TRACE("Updated nextBlockPosition after never-written DDT write to %" PRIu64, ctx->nextBlockPosition);
|
TRACE("Updated nextBlockPosition after never-written DDT write to %" PRIu64, ctx->nextBlockPosition);
|
||||||
|
|
||||||
// Free the cached table
|
// Free the cached table
|
||||||
@@ -1203,6 +1205,8 @@ void set_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sectorAddress, bool
|
|||||||
// Update nextBlockPosition to ensure future blocks don't overwrite the DDT
|
// Update nextBlockPosition to ensure future blocks don't overwrite the DDT
|
||||||
uint64_t ddtTotalSize = sizeof(DdtHeader2) + ddtHeader.length;
|
uint64_t ddtTotalSize = sizeof(DdtHeader2) + ddtHeader.length;
|
||||||
ctx->nextBlockPosition = (endOfFile + ddtTotalSize + alignmentMask) & ~alignmentMask;
|
ctx->nextBlockPosition = (endOfFile + ddtTotalSize + alignmentMask) & ~alignmentMask;
|
||||||
|
blockOffset = ctx->nextBlockPosition;
|
||||||
|
offset = 0;
|
||||||
TRACE("Updated nextBlockPosition after DDT write to %" PRIu64, ctx->nextBlockPosition);
|
TRACE("Updated nextBlockPosition after DDT write to %" PRIu64, ctx->nextBlockPosition);
|
||||||
|
|
||||||
fseek(ctx->imageStream, savedPos, SEEK_SET);
|
fseek(ctx->imageStream, savedPos, SEEK_SET);
|
||||||
|
|||||||
Reference in New Issue
Block a user