diff options
author | Alexander Ivanov <alexander.ivanov@virtuozzo.com> | 2023-04-24 11:31:38 +0200 |
---|---|---|
committer | Hanna Czenczek <hreitz@redhat.com> | 2023-06-05 13:13:50 +0200 |
commit | 679749ce41bc61ff92fb857a66497a03c241b8c2 (patch) | |
tree | ced276fe889a23d3340b4fb83a990c85d24d49e3 | |
parent | ab2d739c417ccc7c7bd6c805899c06992bf3bfb1 (diff) |
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>
-rw-r--r-- | block/parallels.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/block/parallels.c b/block/parallels.c index 204d20685b..ea382e8382 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -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); |