diff options
-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 |