]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
numfmt: avoid unlikely integer overflow
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Oct 2019 19:38:15 +0000 (12:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Oct 2019 19:41:51 +0000 (12:41 -0700)
* src/numfmt.c (parse_format_string): Report overflow if
pad < -LONG_MAX, since that can’t be negated.

src/numfmt.c

index 305a8860394d2559330765a809e8283cf9d2fa11..c56641cfd6af596072e7a675913f091d02258628 100644 (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));