From: Theodore Ts'o Date: Mon, 2 Apr 2007 23:27:44 +0000 (-0400) Subject: Fix potential infinite loop in e2fsck on really big filesystems X-Git-Tag: E2FSPROGS-1_40~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=641b66b;p=thirdparty%2Fe2fsprogs.git Fix potential infinite loop in e2fsck on really big filesystems Prevent floating point precision errors on really big filesystems from causing the search interpolation algorithm in the icount abstraction from looping forever. Addresses Debian Bug: #411838 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 7d55e9d90..b5c9add61 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,10 @@ +2007-04-02 Theodore Tso + + * icount.c (get_icount_el): Prevent floating point precision + errors on really big filesystems from causing the search + interpolation algorithm loop forever. (Addresses Debian + Bug: #411838) + 2007-03-21 Theodore Tso * imager.c (ext2fs_image_inode_write), inode.c diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index c8cdc2518..efc74c097 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -247,9 +247,14 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, range = 0; else if (ino > highval) range = 1; - else + else { range = ((float) (ino - lowval)) / (highval - lowval); + if (range > 0.9) + range = 0.9; + if (range < 0.1) + range = 0.1; + } mid = low + ((int) (range * (high-low))); } #endif