From: Victoria Dye via GitGitGadget Date: Mon, 01 Aug 2022 21:14:54 GMT Subject: [PATCH 3/7] builtin/bugreport.c: avoid size_t overflow Message-ID: In-Reply-To: From: Victoria Dye Avoid size_t overflow when reporting the available disk space in 'get_disk_info' by casting the block size and available block count to 'uint64_t' before multiplying them. Without this change, 'st_mult' would (correctly) report size_t overflow on 32-bit systems at or exceeding 2^32 bytes of available space. Signed-off-by: Victoria Dye --- builtin/bugreport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/bugreport.c b/builtin/bugreport.c index 35b1fc48bf1..720889a37ad 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -258,7 +258,7 @@ static int get_disk_info(struct strbuf *out) } strbuf_addf(out, "Available space on '%s': ", buf.buf); - strbuf_humanise_bytes(out, st_mult(stat.f_bsize, stat.f_bavail)); + strbuf_humanise_bytes(out, (uint64_t)stat.f_bsize * (uint64_t)stat.f_bavail); strbuf_addf(out, " (mount flags 0x%lx)\n", stat.f_flag); strbuf_release(&buf); #endif -- gitgitgadget