From: Jeffy Chen Date: Wed, 3 Feb 2016 10:13:55 +0000 (+0800) Subject: fastboot: sparse: fix sparse blocks calculation X-Git-Tag: v2016.05-rc1~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d3bafe32ca47bc3872837c1fe7874f9913de103f;p=u-boot fastboot: sparse: fix sparse blocks calculation It may overflow in sparse_block_size_to_storage, use uint64_t instead in the calculation. Signed-off-by: Jeffy Chen --- diff --git a/common/image-sparse.c b/common/image-sparse.c index dffe844d54..2433192b20 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c @@ -64,7 +64,8 @@ static unsigned int sparse_block_size_to_storage(unsigned int size, sparse_storage_t *storage, sparse_header_t *sparse) { - return size * sparse->blk_sz / storage->block_sz; + return (unsigned int)lldiv((uint64_t)size * sparse->blk_sz, + storage->block_sz); } static bool sparse_chunk_has_buffer(chunk_header_t *chunk)