]> git.ipfire.org Git - thirdparty/coreutils.git/commit
numfmt: avoid integer overflow when rounding
authorPádraig Brady <P@draigBrady.com>
Sun, 21 Jun 2015 03:04:29 +0000 (04:04 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 22 Jun 2015 01:02:05 +0000 (02:02 +0100)
commita3c3e1e9e6d2d953692f1eb24efa9ac7c7448044
tree511d87148bec56ccc4ea3a3d4006a313fec32439
parent0a279f619055cc165bb3cfa3bb737cdd28ed4d70
numfmt: avoid integer overflow when rounding

Due to existing limits this is usually triggered
with an increased precision.  We also add further
restrictions to the output of increased precision numbers.

* src/numfmt.c (simple_round): Avoid intmax_t overflow.
(simple_strtod_int): Count digits consistently
for precision loss and overflow detection.
(prepare_padded_number): Include the precision
when excluding numbers to output, since the precision
determines the ultimate values used in the rounding scheme
in double_to_human().
* tests/misc/numfmt.pl: Add previously failing test cases.
* NEWS: Mention the fix.
NEWS
src/numfmt.c
tests/misc/numfmt.pl