Whamcloud - gitweb
libext2fs: fix 64bit overflow in ext2fs_block_alloc_stats_range
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 14 Mar 2014 13:35:01 +0000 (09:35 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 14 Mar 2014 13:35:02 +0000 (09:35 -0400)
commitb052dc1c8db93c32dea57f8b84b33367bac31b5b
treea528852142eee3bf2be819902afb46dbda6ccfa5
parent24997f1cd2b3c3ea7a5a2c7fe37013de36a6d8a3
libext2fs: fix 64bit overflow in ext2fs_block_alloc_stats_range

In ext2fs_block_alloc_stats_range(), the quantity "-inuse * n" is
calculated as a signed 32-bit quantity.  Unfortunately, gcc (4.6.3 on
Ubuntu 12.04) doesn't sign-extend this quantity to fill the blk64_t
parameter that ext2fs_free_blocks_count_add() wants, so the end result
is that the superblock gets a ridiculously huge free block count.

Changing the declaration of 'n' to blk64_t seems to fix this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/alloc_stats.c