image-android-sparse: handle images with a size that is not a multiple of the block-size

Round up instead of down, otherwise an don't care block is appended.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Michael Olbrich 2023-09-29 20:46:20 +02:00
parent 4a200b2267
commit 0ef795f3a6

View File

@ -317,7 +317,7 @@ static int android_sparse_generate(struct image *image)
ret = flush_header(image, out_fd, &chunk_header, pos);
if (ret < 0)
return ret;
block = extents[extent].end / sparse->block_size;
block = (extents[extent].end - 1 + sparse->block_size) / sparse->block_size;
}
if (block < block_count) {