diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-09-29 10:23:16 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-09-29 10:23:16 -0400 |
commit | 23bb9b106adcf32c41e1700d0eb17939e55cd6bb (patch) | |
tree | 16558a6042390e4c577d386ebbccb5097e69e271 /lib/e2p | |
parent | ca0d5c6c09755f3784d471dbd83bbbac2279bd73 (diff) | |
download | e2fsprogs-23bb9b106adcf32c41e1700d0eb17939e55cd6bb.tar.gz |
Fix e2p_percent() crash if percentage was zero.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/e2p')
-rw-r--r-- | lib/e2p/ChangeLog | 5 | ||||
-rw-r--r-- | lib/e2p/percent.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index 48834010..75e2cd3b 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,8 @@ +2006-09-29 Theodore Tso <tytso@mit.edu> + + * percent.c (e2p_percent): Fix bug which caused e2p_percent to + crash if the percentage was zero. + 2006-08-30 Theodore Tso <tytso@mit.edu> * percent.c (e2p_percent): Add a new function which accurate and diff --git a/lib/e2p/percent.c b/lib/e2p/percent.c index f4497b6f..b8c936df 100644 --- a/lib/e2p/percent.c +++ b/lib/e2p/percent.c @@ -19,6 +19,8 @@ unsigned int e2p_percent(int percent, unsigned int base) { unsigned int mask = ~((1 << (sizeof(unsigned int) - 1) * 8) - 1); + if (!percent) + return 0; if (100 % percent == 0) return base / (100 / percent); if (mask & base) |