From 3be80bf2a90c5d9d227fa9c920e7a5e0e70f473b Mon Sep 17 00:00:00 2001 From: "William R. Fraser" Date: Sun, 20 Mar 2016 17:44:09 -0700 Subject: [PATCH] wc: fix wrong byte counts when using --files-from0 When using '--files-from0=-', wc reuses the same fstatus struct for each file. However, it doesn't reset the fstatus.failed member between files, which causes wc to skip doing a fstat on all files after the first. This can result in wc seeking past the end of subsequent files, and then over-reporting the byte count. --- src/wc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wc.c b/src/wc.c index 94cbaff..4548235 100644 --- a/src/wc.c +++ b/src/wc.c @@ -806,6 +806,9 @@ main (int argc, char **argv) ok = false; else ok &= wc_file (file_name, &fstatus[nfiles ? i : 0]); + + if (!nfiles) + fstatus[0].failed = 1; } argv_iter_done: -- 2.7.3