GNU bug report logs - #23073
wc reports wrong byte counts when using '--from-files0=-'

Previous Next

Package: coreutils;

Reported by: "William R. Fraser" <wfraser <at> codewise.org>

Date: Mon, 21 Mar 2016 01:29:01 UTC

Severity: normal

Tags: fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "William R. Fraser" <wfraser <at> codewise.org>
To: 23073 <at> debbugs.gnu.org
Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-'
Date: Sun, 20 Mar 2016 17:59:57 -0700 (PDT)
[Message part 1 (text/plain, inline)]
When wc gets its list of files by reading from stdin, using the argument 
'--from-files0=-', it reuses the same fstatus struct for each file.

The problem is that the 'wc' function checks the 'failed' member of this 
struct and if it is <=0, it skips doing fstat on the file. The main loop 
doesn't reset this value between files, so only the first file has fstat 
done on it.

This can result in the 'wc' function seeking past the end of 
subsequent files and then over-reporting their byte counts.

See the attached patch, which resets the fstatus struct in between files 
when reading the file list from stdin.

Thanks,
- Bill Fraser
[0001-wc-fix-wrong-byte-counts-when-using-files-from0.patch (text/plain, attachment)]

This bug report was last modified 6 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.