summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-08-27 08:55:01 +0000
committerJim Meyering <jim@meyering.net>2003-08-27 08:55:01 +0000
commite37cd8f9f44b07a8ab683d9346ab80dec0da1a93 (patch)
treed0d3088ee11d2f36fe12a77f5c70d65deef76089
parente364229e335ec0d5a9d2c40f788e8a4c61f824cc (diff)
downloadcoreutils-e37cd8f9f44b07a8ab683d9346ab80dec0da1a93.tar.xz
(print_it): Avoid buffer overrun that would occur
when the user-specified format string ends with `%'.
-rw-r--r--src/stat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/stat.c b/src/stat.c
index 0bcb1f19a..8b9881653 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -566,7 +566,6 @@ print_it (char const *masterformat, char const *filename,
char *dest = xmalloc (strlen (format) + 1);
-
b = format;
while (b)
{
@@ -583,9 +582,12 @@ print_it (char const *masterformat, char const *filename,
dest[1 + len] = 0;
p += len;
+ b = p + 1;
switch (*p)
{
case '\0':
+ b = NULL;
+ /* fall through */
case '%':
putchar ('%');
break;
@@ -593,7 +595,6 @@ print_it (char const *masterformat, char const *filename,
print_func (dest, *p, filename, data);
break;
}
- b = p + 1;
}
else
{