]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: suppress a theoretical buffer overflow warning
authorPádraig Brady <P@draigBrady.com>
Wed, 11 Jun 2014 23:35:14 +0000 (00:35 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 11 Jun 2014 23:39:13 +0000 (00:39 +0100)
* src/numfmt.c (double_to_human): The printf format is built up in
a stack buffer which is big enough to hold any of the possible formats.
However the size parameter passed to snprintf was too big by 1
when GROUP was true.  So decrease the buffer available to snprintf
to avoid this theoretical in practise but valid coverity warning.

src/numfmt.c

index e8f53fc3f7b3b8945611f37fb5f3a416c950f420..6091bb6bd5824f7d5806654165d9bb57fd44ac6f 100644 (file)
@@ -703,7 +703,7 @@ double_to_human (long double val, int precision,
     *pfmt++ = '\'';
 
   if (zero_padding_width)
-    pfmt += snprintf (pfmt, sizeof (fmt) - 1, "0%ld", zero_padding_width);
+    pfmt += snprintf (pfmt, sizeof (fmt) - 2, "0%ld", zero_padding_width);
 
   devmsg ("double_to_human:\n");