From 641b66bc7ee0a880b0eb0125dff5f8ed8dd5a160 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 2 Apr 2007 19:27:44 -0400 Subject: [PATCH] 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" --- lib/ext2fs/ChangeLog | 7 +++++++ lib/ext2fs/icount.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 7d55e9d..b5c9add 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 c8cdc25..efc74c0 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 -- 1.8.3.1