1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-17 12:52:16 +02:00

numfmt: avoid unlikely integer overflow

* src/numfmt.c (parse_format_string): Report overflow if
pad < -LONG_MAX, since that can’t be negated.
This commit is contained in:
Paul Eggert
2019-10-03 12:38:15 -07:00
parent ac2b4a43e6
commit ba1ea8caee

View File

@@ -1081,7 +1081,7 @@ parse_format_string (char const *fmt)
errno = 0;
pad = strtol (fmt + i, &endptr, 10);
if (errno == ERANGE)
if (errno == ERANGE || pad < -LONG_MAX)
die (EXIT_FAILURE, 0,
_("invalid format %s (width overflow)"), quote (fmt));