summaryrefslogtreecommitdiff
path: root/e2fsck/ea_refcount.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-07-05 20:40:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-07-05 20:40:41 -0400
commitac92f3cc0443f5980775e6c3e86724ed817587f6 (patch)
tree7cda32a0b082fc9393a6f4a56efbefc958beb427 /e2fsck/ea_refcount.c
parent22ff06d5f7a90914f7a90bae420e5be7d2e02ce3 (diff)
downloade2fsprogs-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>
Diffstat (limited to 'e2fsck/ea_refcount.c')
-rw-r--r--e2fsck/ea_refcount.c7
1 files changed, 6 insertions, 1 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