From ac92f3cc0443f5980775e6c3e86724ed817587f6 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 5 Jul 2010 20:40:41 -0400 Subject: e2fsck, resize2fs: fix a fp precision error that can lead to a seg fault Commit 641b66b fixed a floating point precision error which can result in a search algorithm looping forever. It can also result in an array index being out of bounds and causing a segfault. Here are two more cases in e2fsck and resize2fs that need to be fixed. I've just used the same fix from the that commit. Signed-off-by: Lachlan McIlroy Signed-off-by: "Theodore Ts'o" --- resize/extent.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'resize') diff --git a/resize/extent.c b/resize/extent.c index 2ed7591d..f0fb1e00 100644 --- a/resize/extent.c +++ b/resize/extent.c @@ -167,9 +167,14 @@ __u32 ext2fs_extent_translate(ext2_extent extent, __u32 old_loc) range = 0; else if (old_loc > highval) range = 1; - else + else { range = ((float) (old_loc - lowval)) / (highval - lowval); + if (range > 0.9) + range = 0.9; + if (range < 0.1) + range = 0.1; + } mid = low + ((int) (range * (high-low))); } #endif -- cgit v1.2.3