summaryrefslogtreecommitdiff
path: root/resize
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 /resize
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 'resize')
-rw-r--r--resize/extent.c7
1 files changed, 6 insertions, 1 deletions
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