Skip to content

numfmt: --format=%N.Mf silently prints lossy output for very large integers (GNU rejects) #11936

@sylvestre

Description

@sylvestre

Summary

When the combined width/precision of --format=%N.Mf can't faithfully represent a very large integer (roughly above 10¹⁸), GNU numfmt rejects the input with a clear error. uutils skips that check and silently prints the value with precision loss.

Found by fuzz_numfmt.

Reproduction

$ LC_ALL=C /usr/bin/numfmt --format=%5.1f 1000000000000000000
numfmt: value/precision too large to be printed: '1e+18/1' (consider using --to)
(rc=2)

$ LC_ALL=C target/debug/numfmt --format=%5.1f 1000000000000000000
1000000000000000000.0
(rc=0)

Another reproducer (found directly by the fuzzer):

$ LC_ALL=C /usr/bin/numfmt --round=from-zero --padding=-12 --format=%\'5.1f \
      --debug --header=5 --delimiter=: 4544384872967057418 419
numfmt: value/precision too large to be printed: '4.54438e+18/1' (consider using --to)
(rc=2)

$ LC_ALL=C target/debug/numfmt --round=from-zero --padding=-12 --format=%\'5.1f \
      --debug --header=5 --delimiter=: 4544384872967057418 419
4544384872967057418.0
419.0
(rc=0)

Values at or below ~10¹⁷ format identically on both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions