Commit d3bafe32ca47bc3872837c1fe7874f9913de103f

Authored by Jeffy Chen
Committed by Tom Rini
1 parent 9dbdc6ebd4

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>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

common/image-sparse.c
... ... @@ -64,7 +64,8 @@
64 64 sparse_storage_t *storage,
65 65 sparse_header_t *sparse)
66 66 {
67   - return size * sparse->blk_sz / storage->block_sz;
  67 + return (unsigned int)lldiv((uint64_t)size * sparse->blk_sz,
  68 + storage->block_sz);
68 69 }
69 70  
70 71 static bool sparse_chunk_has_buffer(chunk_header_t *chunk)