From e44adcc5bc17363219bb776becc1a5ac3889e9e3 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Wed, 26 Aug 2020 15:08:20 -0300 Subject: [PATCH] btrfs-progs: convert: make ASSERT not truncate cctx.total_bytes value Commit "btrfs-progs: convert: prevent 32bit overflow for cctx->total_bytes" added an assert to ensure that cctxx.total_bytes did not overflow, but this ASSERT calls assert_trace, which expects a long value. By converting the u64 to long overflows in a 32bit machine, leading the assert_trace to be triggered since cctx.total_bytes turns to zero. Fix this problem by comparing the cctx.total_bytes with zero when calling ASSERT. Reviewed-by: Qu Wenruo Signed-off-by: Marcos Paulo de Souza Signed-off-by: David Sterba --- convert/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert/main.c b/convert/main.c index df6a2ae3..6968c65d 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1136,7 +1136,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, if (ret) goto fail; - ASSERT(cctx.total_bytes); + ASSERT(cctx.total_bytes != 0); blocksize = cctx.blocksize; total_bytes = (u64)blocksize * (u64)cctx.block_count; if (blocksize < 4096) {