[PATCH] fastboot: Fix overflow when calculating chunk size

Sean Anderson sean.anderson at seco.com
Mon Apr 19 16:13:00 CEST 2021

On 4/19/21 12:31 AM, Heiko Schocher wrote:
 > Hello Sean,
 > On 16.04.21 23:58, Sean Anderson wrote:
 >> If a chunk was larger than 4GiB, then chunk_data_sz would overflow and
 >> blkcnt would not be calculated correctly. Upgrade it to a u64 and cast
 >> its multiplicands as well. Also fix bytes_written while we're at it.
 >> Signed-off-by: Sean Anderson <sean.anderson at seco.com>
 >> ---
 >>   lib/image-sparse.c | 12 ++++++------
 >>   1 file changed, 6 insertions(+), 6 deletions(-)
 > Wow chunk size larger than 4G!

Normally filesystems like ext4 put data all around the disk (i.e. the
used-block bitmap). However, if you use a log filesystem (like F2FS),
then all the data is at the beginning of the disk. In that case, it is
fairly easy to end up with a 4GiB or greater "don't care" chunk taking
up most of the disk.


 > But patch seems valid, so
 > Reviewed-by: Heiko Schocher <hs at denx.de>
 > bye,
 > Heiko

More information about the U-Boot mailing list