summaryrefslogtreecommitdiff
path: root/common/image-sparse.c
diff options
context:
space:
mode:
authorJeffy Chen <jeffy.chen@rock-chips.com>2016-02-03 18:13:55 +0800
committerTom Rini <trini@konsulko.com>2016-04-11 12:44:37 -0400
commitd3bafe32ca47bc3872837c1fe7874f9913de103f (patch)
tree8059323b5600e2de6dbadab15f5cef82c5c58318 /common/image-sparse.c
parent9dbdc6ebd4db60effebefcf8d541cf598712e3b7 (diff)
downloadu-boot-d3bafe32ca47bc3872837c1fe7874f9913de103f.tar.gz
u-boot-d3bafe32ca47bc3872837c1fe7874f9913de103f.tar.bz2
u-boot-d3bafe32ca47bc3872837c1fe7874f9913de103f.zip
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 <jeffy.chen@rock-chips.com>
Diffstat (limited to 'common/image-sparse.c')
-rw-r--r--common/image-sparse.c3
1 files changed, 2 insertions, 1 deletions
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)