From 0ef795f3a665309974c2a33d866f214a067e1bbf Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Fri, 29 Sep 2023 20:46:20 +0200 Subject: [PATCH] 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 --- image-android-sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image-android-sparse.c b/image-android-sparse.c index c5dee42..7d4d779 100644 --- a/image-android-sparse.c +++ b/image-android-sparse.c @@ -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) {