From d05508956734d55f7ee286085a1f6570d11848b7 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 28 Dec 2013 22:25:11 -0500 Subject: [PATCH] e2freefrag: avoid integer overflow when reporting free space statistics An integer overflow could happen if the file system is large and has very large contiguous chunks of free space. Addresses-Debian-Bug: #718205 Signed-off-by: "Theodore Ts'o" --- misc/e2freefrag.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index 58f1ff5..612ca44 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -172,10 +172,10 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info, /* Display chunk information in KB */ if (info->real_free_chunks) { - info->min = (info->min * fs->blocksize) >> 10; - info->max = (info->max * fs->blocksize) >> 10; - info->avg = (info->avg / info->real_free_chunks * - fs->blocksize) >> 10; + unsigned int scale = fs->blocksize >> 10; + info->min = info->min * scale; + info->max = info->max * scale; + info->avg = info->avg / info->real_free_chunks * scale; } else { info->min = 0; } -- 1.8.3.1