diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-07-05 20:40:41 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-07-05 20:40:41 -0400 |
commit | ac92f3cc0443f5980775e6c3e86724ed817587f6 (patch) | |
tree | 7cda32a0b082fc9393a6f4a56efbefc958beb427 | |
parent | 22ff06d5f7a90914f7a90bae420e5be7d2e02ce3 (diff) | |
download | e2fsprogs-ac92f3cc0443f5980775e6c3e86724ed817587f6.tar.gz |
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 <lmcilroy@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | e2fsck/ea_refcount.c | 7 | ||||
-rw-r--r-- | resize/extent.c | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/e2fsck/ea_refcount.c b/e2fsck/ea_refcount.c index 39f2db7f..b10cfffa 100644 --- a/e2fsck/ea_refcount.c +++ b/e2fsck/ea_refcount.c @@ -196,9 +196,14 @@ retry: range = 0; else if (blk > highval) range = 1; - else + else { range = ((float) (blk - lowval)) / (highval - lowval); + if (range > 0.9) + range = 0.9; + if (range < 0.1) + range = 0.1; + } mid = low + ((int) (range * (high-low))); } #endif 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 |