|
From: | Paul Eggert |
Subject: | bug#18621: [BUG] wc -c incorrectly counts bytes in /sys |
Date: | Tue, 07 Oct 2014 00:09:24 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 |
Paul Eggert wrote:
How about if we change usable_st_size to return false for these proc files
Attached is a better idea, I hope. I audited the coreutils code to look for problematic uses of SEEK_END or st_size when reading files (I didn't look at writing; one can of worms at a time).
The attached patch still needs a changelog entry and test cases. The basic idea is to not trust st_size when it's <= ST_BLKSIZE. This fixes bugs in 'head', 'od', 'split', 'tac', 'tail', and 'wc' when applied to input files in proc or sysfs file systems.
Here's an example bug fixed by this patch: $ cat /sys/kernel/profiling 0 $ tail -2c /sys/kernel/profiling $ This should be: $ cat /sys/kernel/profiling 0 $ tail -2c /sys/kernel/profiling 0 $
procsys.diff
Description: Text document
[Prev in Thread] | Current Thread | [Next in Thread] |