Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
parallels: Fix image_end_offset and data_end after out-of-image check
Set data_end to the end of the last cluster inside the image. In such a
way we can be sure that corrupted offsets in the BAT can't affect on the
image size. If there are no allocated clusters set image_end_offset by
data_end.

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Message-Id: <20230424093147.197643-4-alexander.ivanov@virtuozzo.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
  • Loading branch information
AlexanderIvanov-Virtuozzo authored and XanClic committed Jun 5, 2023
1 parent ab2d739 commit 679749c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion block/parallels.c
Expand Up @@ -490,7 +490,13 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
}
}

res->image_end_offset = high_off + s->cluster_size;
if (high_off == 0) {
res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
} else {
res->image_end_offset = high_off + s->cluster_size;
s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS;
}

if (size > res->image_end_offset) {
int64_t count;
count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
Expand Down

0 comments on commit 679749c

Please sign in to comment.