summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Fries2017-04-18 11:39:24 -0500
committerChris Fries2017-04-19 10:32:45 -0500
commit3738968ed8587bb742ce8aed3ec61b3c9663b9d8 (patch)
treee0a5b0c900158a34e7e6092e5ff7b0d60eb728cd /libsparse
parent8b318d0c26c89acd7c716fb571bfd08d4393d12f (diff)
downloadplatform-system-core-3738968ed8587bb742ce8aed3ec61b3c9663b9d8.tar.gz
platform-system-core-3738968ed8587bb742ce8aed3ec61b3c9663b9d8.tar.xz
platform-system-core-3738968ed8587bb742ce8aed3ec61b3c9663b9d8.zip
libsparse: Fix odd-sized input files total_blks
If the input file isn't a multiple of block_size, count the trailing bit as a block in the output, otherwise bootloader will try to write past the last declared block in the sparse file. Test: Run sparse_test Bug: 37339998 Change-Id: Iec143107d15795c6a6f4d3ea7b7515f6f16adcae
Diffstat (limited to 'libsparse')
-rw-r--r--libsparse/output_file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libsparse/output_file.c b/libsparse/output_file.c
index 21159987f..51e60ef79 100644
--- a/libsparse/output_file.c
+++ b/libsparse/output_file.c
@@ -584,7 +584,7 @@ static int output_file_init(struct output_file *out, int block_size,
584 .file_hdr_sz = SPARSE_HEADER_LEN, 584 .file_hdr_sz = SPARSE_HEADER_LEN,
585 .chunk_hdr_sz = CHUNK_HEADER_LEN, 585 .chunk_hdr_sz = CHUNK_HEADER_LEN,
586 .blk_sz = out->block_size, 586 .blk_sz = out->block_size,
587 .total_blks = out->len / out->block_size, 587 .total_blks = DIV_ROUND_UP(out->len, out->block_size),
588 .total_chunks = chunks, 588 .total_chunks = chunks,
589 .image_checksum = 0 589 .image_checksum = 0
590 }; 590 };