From: Jim Meyering Date: Sat, 12 Mar 2005 10:54:20 +0000 (+0000) Subject: Invoking stat -c FMT with a lone format directive of %s, %f, %h, %s, X-Git-Tag: CPPI-1_12~1312 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9d98362233ab51869b8829f91d70f37a54be5a5;p=thirdparty%2Fcoreutils.git Invoking stat -c FMT with a lone format directive of %s, %f, %h, %s, could cause a buffer overrun error. (print_it): Allocate 2 more bytes, to accommodate our conversion of the stat %s format string to the longer printf %llu one. Patch from Guochun Shi. --- diff --git a/src/stat.c b/src/stat.c index f9f1459189..2f4609c902 100644 --- a/src/stat.c +++ b/src/stat.c @@ -534,7 +534,7 @@ print_it (char const *masterformat, char const *filename, /* create a working copy of the format string */ char *format = xstrdup (masterformat); - char *dest = xmalloc (strlen (format) + 1); + char *dest = xmalloc (strlen (format) + 2 + 1); b = format; while (b)