mirror of
https://github.com/pengutronix/genimage.git
synced 2024-11-23 17:53:52 +08:00
image-android-sparse: Fix #224: truncated image generated
When source image file ends with empty (sparse) area, this area is skipped and incomplete sparse file is generated. Signed-off-by: Wojciech Nizinski <wojciech.nizinski@grinn-global.com>
This commit is contained in:
parent
5c3b0c4bae
commit
4a200b2267
@ -320,6 +320,19 @@ static int android_sparse_generate(struct image *image)
|
||||
block = extents[extent].end / sparse->block_size;
|
||||
}
|
||||
|
||||
if (block < block_count) {
|
||||
header.input_chunks++;
|
||||
chunk_header.chunk_type = SPARSE_DONT_CARE;
|
||||
chunk_header.blocks = block_count - block;
|
||||
chunk_header.size = sizeof(chunk_header);
|
||||
ret = flush_header(image, out_fd, &chunk_header, -1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < chunk_header.blocks; ++i)
|
||||
crc32 = crc32_next(zeros, sparse->block_size, crc32);
|
||||
}
|
||||
|
||||
header.input_chunks++;
|
||||
chunk_header.chunk_type = SPARSE_CRC32;
|
||||
chunk_header.blocks = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user