mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fix a bug in the KiB and MiB computation in add_xnum_to_string
where the fractional part overflowed to 0 before the integer part was incremented. Thanks to Marti Raudsepp for finding this bug and Marti and pasky for the fix.
This commit is contained in:
commit
e31a66745a
3
AUTHORS
3
AUTHORS
@ -337,6 +337,9 @@ Martin Kavalec <martin@penguin.cz>
|
||||
Martin Norback <d95mback@dtek.chalmers.se>
|
||||
Swedish translation
|
||||
|
||||
Marti Raudsepp <marti@juffo.org>
|
||||
KiB/MiB computation bugfix
|
||||
|
||||
Matthew Mueller <donut@azstarnet.com>
|
||||
Random hacking
|
||||
|
||||
|
@ -176,12 +176,12 @@ add_xnum_to_string(struct string *string, off_t xnum)
|
||||
/* Mebi (Mi), 2^20 */
|
||||
if (xnum >= 1024 * 1024) {
|
||||
suff[0] = 'M';
|
||||
d = (xnum / (int) ((int) (1024 * 1024) / (int) 10)) % 10;
|
||||
d = (xnum * (int) 10 / (int) ((int) (1024 * 1024))) % 10;
|
||||
xnum /= 1024*1024;
|
||||
/* Kibi (Ki), 2^10 */
|
||||
} else if (xnum >= 1024) {
|
||||
suff[0] = 'K';
|
||||
d = (xnum / (int) ((int) 1024 / (int) 10)) % 10;
|
||||
d = (xnum * (int) 10 / (int) 1024) % 10;
|
||||
xnum /= 1024;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user