summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-10-23 17:20:01 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-10-23 17:24:38 -0700
commit7d93a082b6e3ece0b120a5150d2020c7fa11b2f5 (patch)
treebf963fe6dfed9a7451f2a6e73d972f16ec14c4c4 /src/du.c
parentd5d82ecf3b0f370216c12e0f8163f0a5249da91e (diff)
downloadcoreutils-7d93a082b6e3ece0b120a5150d2020c7fa11b2f5.tar.xz
du: don't print junk when diagnosing out-of-range time stamps
* src/du.c (show_date): Fix call to fputs with a buffer that contains some uninitialized data. * tests/Makefile.am (TESTS): Add du/big-timestamp. * tests/du/bigtime: New file, which checks for the bug.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/du.c b/src/du.c
index 3d9257934..4951826ea 100644
--- a/src/du.c
+++ b/src/du.c
@@ -351,8 +351,9 @@ show_date (const char *format, struct timespec when)
if (! tm)
{
char buf[INT_BUFSIZE_BOUND (intmax_t)];
- error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
- fputs (buf, stdout);
+ char *when_str = timetostr (when.tv_sec, buf);
+ error (0, 0, _("time %s is out of range"), when_str);
+ fputs (when_str, stdout);
return;
}