From: Paul Eggert Date: Thu, 3 Oct 2019 19:38:15 +0000 (-0700) Subject: numfmt: avoid unlikely integer overflow X-Git-Tag: v8.32~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba1ea8caeebe9e93a40a5f05d6ff3df2afdc63ab;p=thirdparty%2Fcoreutils.git numfmt: avoid unlikely integer overflow * src/numfmt.c (parse_format_string): Report overflow if pad < -LONG_MAX, since that can’t be negated. --- diff --git a/src/numfmt.c b/src/numfmt.c index 305a886039..c56641cfd6 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -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));