소스 검색

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>
Jeffy Chen 9 년 전
부모
커밋
d3bafe32ca
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      common/image-sparse.c

+ 2 - 1
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)