[PATCH 3/7] builtin/bugreport.c: avoid size_t overflow
From: Victoria Dye via GitGitGadget <hidden>
Date: 2022-08-01 21:15:11
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Victoria Dye via GitGitGadget <hidden>
Date: 2022-08-01 21:15:11
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Victoria Dye <redacted> 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 <redacted> --- 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