From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: "William R. Fraser" Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 21 Mar 2016 01:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 23073@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145852372128582 (code B ref -1); Mon, 21 Mar 2016 01:29:01 +0000 Received: (at submit) by debbugs.gnu.org; 21 Mar 2016 01:28:41 +0000 Received: from localhost ([127.0.0.1]:56049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahoe8-0007Qv-9R for submit@debbugs.gnu.org; Sun, 20 Mar 2016 21:28:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56172) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahoCX-0006lc-Sh for submit@debbugs.gnu.org; Sun, 20 Mar 2016 21:00:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahoCS-0007BY-29 for submit@debbugs.gnu.org; Sun, 20 Mar 2016 21:00:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahoCR-0007BU-Vh for submit@debbugs.gnu.org; Sun, 20 Mar 2016 21:00:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahoCQ-0008Jt-VE for bug-coreutils@gnu.org; Sun, 20 Mar 2016 21:00:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahoCN-00079c-Qd for bug-coreutils@gnu.org; Sun, 20 Mar 2016 21:00:02 -0400 Received: from sfo-arch1.nimbus.codewise.org ([192.241.211.151]:57514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahoCN-00079I-KV for bug-coreutils@gnu.org; Sun, 20 Mar 2016 20:59:59 -0400 Received: by sfo-arch1.nimbus.codewise.org (Postfix, from userid 1000) id 73527A21FD; Sun, 20 Mar 2016 17:59:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by sfo-arch1.nimbus.codewise.org (Postfix) with ESMTP id 5081EA165A for ; Sun, 20 Mar 2016 17:59:57 -0700 (PDT) Date: Sun, 20 Mar 2016 17:59:57 -0700 (PDT) From: "William R. Fraser" X-X-Sender: wfraser@sfo-arch1.nimbus.codewise.org Message-ID: User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="-239036461-1233779491-1458521997=:10629" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Sun, 20 Mar 2016 21:28:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---239036461-1233779491-1458521997=:10629 Content-Type: text/plain; format=flowed; charset=US-ASCII 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 ---239036461-1233779491-1458521997=:10629 Content-Type: text/plain; charset=US-ASCII; name=0001-wc-fix-wrong-byte-counts-when-using-files-from0.patch Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: 0001-wc-fix-wrong-byte-counts-when-using-files-from0.patch Content-Disposition: attachment; filename=0001-wc-fix-wrong-byte-counts-when-using-files-from0.patch RnJvbSAzYmU4MGJmMmE5MGM1ZDlkMjI3ZmE5YzkyMGU3YTVlMGU3MGY0NzNi IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQ0KRnJvbTogIldpbGxpYW0gUi4g RnJhc2VyIiA8d2ZyYXNlckBjb2Rld2lzZS5vcmc+DQpEYXRlOiBTdW4sIDIw IE1hciAyMDE2IDE3OjQ0OjA5IC0wNzAwDQpTdWJqZWN0OiBbUEFUQ0hdIHdj OiBmaXggd3JvbmcgYnl0ZSBjb3VudHMgd2hlbiB1c2luZyAtLWZpbGVzLWZy b20wDQoNCldoZW4gdXNpbmcgJy0tZmlsZXMtZnJvbTA9LScsIHdjIHJldXNl cyB0aGUgc2FtZSBmc3RhdHVzIHN0cnVjdCBmb3IgZWFjaA0KZmlsZS4gSG93 ZXZlciwgaXQgZG9lc24ndCByZXNldCB0aGUgZnN0YXR1cy5mYWlsZWQgbWVt YmVyIGJldHdlZW4gZmlsZXMsDQp3aGljaCBjYXVzZXMgd2MgdG8gc2tpcCBk b2luZyBhIGZzdGF0IG9uIGFsbCBmaWxlcyBhZnRlciB0aGUgZmlyc3QuDQoN ClRoaXMgY2FuIHJlc3VsdCBpbiB3YyBzZWVraW5nIHBhc3QgdGhlIGVuZCBv ZiBzdWJzZXF1ZW50IGZpbGVzLCBhbmQgdGhlbg0Kb3Zlci1yZXBvcnRpbmcg dGhlIGJ5dGUgY291bnQuDQotLS0NCiBzcmMvd2MuYyB8IDMgKysrDQogMSBm aWxlIGNoYW5nZWQsIDMgaW5zZXJ0aW9ucygrKQ0KDQpkaWZmIC0tZ2l0IGEv c3JjL3djLmMgYi9zcmMvd2MuYw0KaW5kZXggOTRjYmFmZi4uNDU0ODIzNSAx MDA2NDQNCi0tLSBhL3NyYy93Yy5jDQorKysgYi9zcmMvd2MuYw0KQEAgLTgw Niw2ICs4MDYsOSBAQCBtYWluIChpbnQgYXJnYywgY2hhciAqKmFyZ3YpDQog ICAgICAgICBvayA9IGZhbHNlOw0KICAgICAgIGVsc2UNCiAgICAgICAgIG9r ICY9IHdjX2ZpbGUgKGZpbGVfbmFtZSwgJmZzdGF0dXNbbmZpbGVzID8gaSA6 IDBdKTsNCisNCisgICAgICBpZiAoIW5maWxlcykNCisgICAgICAgIGZzdGF0 dXNbMF0uZmFpbGVkID0gMTsNCiAgICAgfQ0KICBhcmd2X2l0ZXJfZG9uZToN CiANCi0tIA0KMi43LjMNCg0K ---239036461-1233779491-1458521997=:10629-- From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 21 Mar 2016 15:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "William R. Fraser" , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.145857340029079 (code B ref 23073); Mon, 21 Mar 2016 15:17:01 +0000 Received: (at 23073) by debbugs.gnu.org; 21 Mar 2016 15:16:40 +0000 Received: from localhost ([127.0.0.1]:57082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai1ZP-0007Yx-Qz for submit@debbugs.gnu.org; Mon, 21 Mar 2016 11:16:39 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:43523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai1ZO-0007Yp-4K for 23073@debbugs.gnu.org; Mon, 21 Mar 2016 11:16:38 -0400 Received: from localhost.localdomain (unknown [109.77.139.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id B06151DC; Mon, 21 Mar 2016 15:16:36 +0000 (GMT) References: From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <56F01053.4030605@draigBrady.com> Date: Mon, 21 Mar 2016 15:16:35 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 21/03/16 00:59, William R. Fraser wrote: > 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. Ouch. This seems to be since v7.0-96-gc2e56e0 It would also mean there would be a lot of redundant reading if the initial file was significantly smaller than any other file. $ truncate -s1G wc.big $ touch wc.small $ printf '%s\0' wc.big wc.small | wc -c --files0-from=- 1073741824 wc.big 1073741760 wc.small 2147483584 total We'll submit a full patch in your name. thanks! Pádraig. From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 21 Mar 2016 17:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.14585808347984 (code B ref 23073); Mon, 21 Mar 2016 17:21:02 +0000 Received: (at 23073) by debbugs.gnu.org; 21 Mar 2016 17:20:34 +0000 Received: from localhost ([127.0.0.1]:57192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai3VK-00024i-0o for submit@debbugs.gnu.org; Mon, 21 Mar 2016 13:20:34 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:53436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai3VH-00024Q-Uq for 23073@debbugs.gnu.org; Mon, 21 Mar 2016 13:20:32 -0400 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MMrlb-1ahmmU2Iet-008XTu; Mon, 21 Mar 2016 18:20:25 +0100 References: <56F01053.4030605@draigBrady.com> From: Bernhard Voelker Message-ID: <56F02D59.80801@bernhard-voelker.de> Date: Mon, 21 Mar 2016 18:20:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56F01053.4030605@draigBrady.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:v2Y0cwiJK2pif6UBMQ5pqZtM97+z8z9FA4htSfL5ZlZFzKkH6pu j94BG3o+MpQcNf+WQ/ZZflL3Vj14LPBr5u3QWFcqYtPkWOu6aDoLSlnpT8+z15RZm3XNiR0 n3SkEfywdG0Q+vfJLTH8A8uZf1dtRiAJOY+mKrwad6EBdSq/sc9TCbAtimNVPLunSHRAx1x CeSPi8EJRzkBTr242aqdA== X-UI-Out-Filterresults: notjunk:1;V01:K0:kG5SQ44U4gM=:gC8EcW/owL2MYqCkXa0ZQF pbEu9T0eFI5Kxa7pi6IiDrkIDByGNKHoxppOImWaTcrya3JdpEaJUzpN9v7yuBMUnl7dzjQjN D8+X89bJmKFNZ1FcqozbtQ09kUQ0FE98F5AP05984lf/cxFd2nXEyN2uuJ+Cte1Qn9KBqL98N RdQOU1SCxedbModMObu5Pgk5O1RyZ+wJSBRx8ITdrnbJZwBjTAxLGqpF8abCxudj2S1rNOxaV FvsMJ51DH2QC6/2XoBUvFJk4pJdW0GPBhnoW7xM8yfs11NU/9CttLmEdMXcSkAYS2CgblRLdl VXZ2ljdLwVEKupYPMVWQrS/8eKIawocUHV7rsaBgrpLMmWFB646AX6OADKQBRbkhH40Ur3Ts4 eJv/Jp1eSvxpzo8IEYwqVxmbzYmCq3TdvJlFwHX9kGxzV3lTahGdCW0QJkAcP+2shR6BGHKp0 kM2Td80N8EO3peMHdlxYeF1O5rQj6zUmuF+2fPas8QxWPS9798mnKNfNDLOs0mfXSplYUtZXj dAlM5aBzR/jgrCUz58F6b++T0px0XQmyBHkzybHXuJNU8YoDk3fG7vNcneh0AKvIJGdmnWLAR jaR0I1NRWpgpTMTxddG/Gg5dJqGnWpNYd2H3T/P0qwywF0A2aOeuwcIQybWVvwG1cIfQWMbEs 7FpK4/QxCL5SaYI2Dl3eUEAEosifZ0piZYj08xiRpcrznvhSSndZQ26FEuwNkn/XadfEhhTl3 6IXZoKNcGGOIxEFg X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 03/21/2016 04:16 PM, Pádraig Brady wrote: > On 21/03/16 00:59, William R. Fraser wrote: >> 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. > > Ouch. This seems to be since v7.0-96-gc2e56e0 > It would also mean there would be a lot of redundant reading > if the initial file was significantly smaller than any other file. > > $ truncate -s1G wc.big > $ touch wc.small > $ printf '%s\0' wc.big wc.small | wc -c --files0-from=- > 1073741824 wc.big > 1073741760 wc.small > 2147483584 total > > We'll submit a full patch in your name. Interesting enough, there seems to be a threshold to trigger the bug: $ touch wc.small $ seq 1000 > wc.big $ printf '%s\0' wc.big wc.small | wc -c --files0-from=- 3893 wc.big 0 wc.small 3893 total $ seq 10000 > wc.big $ printf '%s\0' wc.big wc.small | wc -c --files0-from=- 48894 wc.big 45067 wc.small 93961 total That's why I couldn't reproduce it this morning. Have a nice day, Berny From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: Jim Meyering Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 21 Mar 2016 18:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "William R. Fraser" Cc: 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.145858587416033 (code B ref 23073); Mon, 21 Mar 2016 18:45:02 +0000 Received: (at 23073) by debbugs.gnu.org; 21 Mar 2016 18:44:34 +0000 Received: from localhost ([127.0.0.1]:57275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai4ob-0004AX-Of for submit@debbugs.gnu.org; Mon, 21 Mar 2016 14:44:33 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:33403) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai4oa-0004AL-6u for 23073@debbugs.gnu.org; Mon, 21 Mar 2016 14:44:32 -0400 Received: by mail-oi0-f51.google.com with SMTP id d205so148957755oia.0 for <23073@debbugs.gnu.org>; Mon, 21 Mar 2016 11:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=r4tpbKm44NuVUs+OkczAs8U2NX6W2fD4AReVtrrYKoI=; b=jGiCzaYIXAtTINylT9ZLrPNlANCvPfVMFGaGYCelzwUGeCpv12kSP0ZIq+4/tMWR46 hG4fwPS/+VTppEH/O5YWmyXbTyv97LwyX513LzHOOas4MB2UW0FEYoh/FoydU41/E9y/ vhOpjlX851gBUdFoMX6lbRnmw2hDnM2XcHCW0UQ7i9BkyyOyYKk2RyG13qk9NhstRCcO h+2VU1QrgO0e1en6fKgiWk8BuVCW8GZem2DCaA/4+8rbdnuxzJjzYmhzF1L8ej7VLYRv SjMHFVz8F6goey2dCf3j6WL7Gx5N9NZwg9jllZrtoWy+ruXv+pI/Ygt3sWNo/Y30+C70 1u+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=r4tpbKm44NuVUs+OkczAs8U2NX6W2fD4AReVtrrYKoI=; b=KI2ihvFvrCQd5ma3BvjDe/vsWygzJjynPsm/4KGI1GLeujKILkFaITsRKBGDz29dWh 9I5KZb4+RDrxM/nEJnlHiR49UacmctwbTOQq5A8He5MRNalqr8mK82uB2lKfrW3qR95M MKgHniC7qIL3iGGgo5RPUAZy5s6JqzzLTTEk7lDxl9OHqbB7XZnZr+Mu5vIoC/mqMe+j 7h08duujvpitxFUB4+TFofhKRX5OKuMQt0Lfa1JRoPEQfuQPR6fIrmfzBkGlmhfOP4RM 4uEtpcBIEH+doOvobrAKlz8gex3B9zhe1v9WBXxGqJ+0cDiuNt0fETe2yVy26W5XSwH9 OYQg== X-Gm-Message-State: AD7BkJIlDHVgBIP0es4iiEG0J7C3IwkBgkunArI7gtmMlIRi5v66LK5/z5hXv4lh6kBgyheN2CGYlRxOMVCa/A== X-Received: by 10.157.40.59 with SMTP id m56mr1332141otb.103.1458585866542; Mon, 21 Mar 2016 11:44:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.44.5 with HTTP; Mon, 21 Mar 2016 11:44:06 -0700 (PDT) In-Reply-To: References: From: Jim Meyering Date: Mon, 21 Mar 2016 11:44:06 -0700 X-Google-Sender-Auth: H0gz8fYICEN-okbfX0rvwhUmfLQ Message-ID: Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On Sun, Mar 20, 2016 at 5:59 PM, William R. Fraser wrote: > 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. Thank you for the patch and report for what looks like a bug in code I wrote. From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 19 Dec 2016 19:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "William R. Fraser" , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.148217403722810 (code B ref 23073); Mon, 19 Dec 2016 19:01:01 +0000 Received: (at 23073) by debbugs.gnu.org; 19 Dec 2016 19:00:37 +0000 Received: from localhost ([127.0.0.1]:47954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ3Aq-0005vq-KE for submit@debbugs.gnu.org; Mon, 19 Dec 2016 14:00:36 -0500 Received: from midir.magicbluesmoke.com ([82.195.144.46]:54424 helo=mail.magicbluesmoke.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ3Ao-0005vh-Ko for 23073@debbugs.gnu.org; Mon, 19 Dec 2016 14:00:35 -0500 Received: from [192.168.1.80] (unknown [109.79.94.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 333D3AC; Mon, 19 Dec 2016 19:00:32 +0000 (GMT) References: <56F01053.4030605@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: Date: Mon, 19 Dec 2016 19:00:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <56F01053.4030605@draigBrady.com> Content-Type: multipart/mixed; boundary="------------E9ED9AE1117275DD96948C42" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------E9ED9AE1117275DD96948C42 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit On 21/03/16 15:16, Pádraig Brady wrote: > On 21/03/16 00:59, William R. Fraser wrote: >> 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. > > Ouch. This seems to be since v7.0-96-gc2e56e0 > It would also mean there would be a lot of redundant reading > if the initial file was significantly smaller than any other file. > > $ truncate -s1G wc.big > $ touch wc.small > $ printf '%s\0' wc.big wc.small | wc -c --files0-from=- > 1073741824 wc.big > 1073741760 wc.small > 2147483584 total Sorry for the delay. I didn't go far enough back in my TODO list so missed this. Proposed patch attached. thanks, Pádraig --------------E9ED9AE1117275DD96948C42 Content-Type: text/x-patch; name="wc-c--files0-from-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="wc-c--files0-from-fix.patch" >From 31bba96cb7dc565719c396b5973085e644939fd5 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 * src/wc.c (main): Reset fstatus[0].failed between files when reusing the fstatus[0] entry in --files-from0 mode. This ensures a stat() is done for each file, avoid incorrect counts and redundant reading. * NEWS: Mention the bug fix. * tests/misc/wc-files0.sh: Add a test case. Fixes http://bugs.gnu.org/23073 --- NEWS | 5 +++++ src/wc.c | 3 +++ tests/misc/wc-files0.sh | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 179c19b..1ed5bd9 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,11 @@ GNU coreutils NEWS -*- outline -*- 158909489063877810457 and 222087527029934481871. [bug introduced in coreutils-8.20] + wc --bytes --files0-from now correctly reports byte counts. + Previously it may have returned values that were too large, + depending on the size of the first file processed. + [bug introduced in coreutils-7.1] + * Noteworthy changes in release 8.26 (2016-11-30) [stable] diff --git a/src/wc.c b/src/wc.c index 412bda0..64df50c 100644 --- a/src/wc.c +++ b/src/wc.c @@ -807,6 +807,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: diff --git a/tests/misc/wc-files0.sh b/tests/misc/wc-files0.sh index 12b7d6a..d92a010 100755 --- a/tests/misc/wc-files0.sh +++ b/tests/misc/wc-files0.sh @@ -25,7 +25,7 @@ printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure_ wc --files0-from=names > out || fail=1 -cat <<\EOF > exp || fail=1 +cat <<\EOF > exp || framework_failure_ 1 1 2 2b 1 2 8 2w 2 3 10 total @@ -48,4 +48,15 @@ printf '%s\0' "$nlname" | wc --files0-from=- > out || fail=1 printf '%s\n' "0 0 0 '1'$'\\n''2'" > exp || framework_failure_ compare exp out || fail=1 +# Ensure correct byte counts, which fails between v7.1 and v8.26 inclusive +truncate -s1G wc.big || framework_failure_ +touch wc.small || framework_failure_ +printf '%s\0' wc.big wc.small | wc -c --files0-from=- >out || fail=1 +cat <<\EOF > exp || framework_failure_ +1073741824 wc.big +0 wc.small +1073741824 total +EOF +compare exp out || fail=1 + Exit $fail -- 2.5.5 --------------E9ED9AE1117275DD96948C42-- From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: "William R. Fraser" Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 19 Dec 2016 19:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.148217717527737 (code B ref 23073); Mon, 19 Dec 2016 19:53:01 +0000 Received: (at 23073) by debbugs.gnu.org; 19 Dec 2016 19:52:55 +0000 Received: from localhost ([127.0.0.1]:47978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ3zT-0007DJ-EF for submit@debbugs.gnu.org; Mon, 19 Dec 2016 14:52:55 -0500 Received: from mail-qt0-f175.google.com ([209.85.216.175]:33264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ3zR-0007D7-Qe for 23073@debbugs.gnu.org; Mon, 19 Dec 2016 14:52:54 -0500 Received: by mail-qt0-f175.google.com with SMTP id p16so155078071qta.0 for <23073@debbugs.gnu.org>; Mon, 19 Dec 2016 11:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=W5HLqOIpw8PuNsB/jrAgBo2xmwuCA9MEM1tNgNXAkaE=; b=AJzxnG8Te44iBa8vybLbpfz9/LODf0CaD+ON0Kl+92WyClIqgmly93gpqkaW/+J5z4 vlqfixp9Hn6ymToiSYa8P9ljYbpC/J+mRq2rfc42PTtKYZs2MJATYsSvtWfn/lgm+R/c 9JVdRpBqWXuNSdS85s/dFPv+q0yJQJBdusMt7FlO9up1J0ZaqhxZ82G4YYLaN7wDMyqq VeiKQ31D99lVSMHSED3rEIZZyWB7Ut998GYk7A+7moWXmNqri3y+U65B4mUM6EvqBrZx y9NpJB31fu10Q2DDvZ8/MhISplsD9wt5b3/4NsO4G0lKgm0UIomYemzm7xA0N6yJSFTj yIQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=W5HLqOIpw8PuNsB/jrAgBo2xmwuCA9MEM1tNgNXAkaE=; b=rhSlRhbcoPSoN66wOaFddBo5Z8yrMH8XBV3ej1Bn3ZOtbOtk5vRA7OQ1TuK9JNeEQ1 AFSh39Wzi+ran4++CjHGj+e+RLKCUnpTuCNBycPADz3KsduZQdwvS0MJ0Y+f/CoDaYLN pB/VXzcy6aBbeY11m5iEbt8diBfu2RNsJmechvp6B+I5k0MxuStjq18RIlA+st6c6yIx fTosZ1MZGt2VwhR+pZDQCCccIb71FKQWfYOWXFA7vpxCjWMgYLeFUZIcGC4oBz9j1LDp 6fgyUL/do4WGgsoF7LDkHNi+DIK8tMZDcOIjfKqlnT2sYpirKQWgs9oOhrk0Sk3RVgjM 7nQQ== X-Gm-Message-State: AIkVDXLdi2Cox8teoVQoEk2a1qGS+GiFhYbzYW8iuNbslGMOOK3gJiJeKA6tESG9iEIkbalo4qRB1+AaKIrVbw== X-Received: by 10.200.37.7 with SMTP id 7mr18940503qtm.102.1482177168291; Mon, 19 Dec 2016 11:52:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.40.4 with HTTP; Mon, 19 Dec 2016 11:52:18 -0800 (PST) In-Reply-To: References: <56F01053.4030605@draigBrady.com> From: "William R. Fraser" Date: Mon, 19 Dec 2016 11:52:18 -0800 X-Google-Sender-Auth: WwoYn03S3GHHuqjdKdy3aZpZ8f8 Message-ID: Content-Type: multipart/alternative; boundary=001a1141f99e9c5d79054408438e X-Spam-Score: -0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) --001a1141f99e9c5d79054408438e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Looks good :) On Mon, Dec 19, 2016 at 11:00 AM, P=C3=A1draig Brady wro= te: > On 21/03/16 15:16, P=C3=A1draig Brady wrote: > > On 21/03/16 00:59, William R. Fraser wrote: > >> When wc gets its list of files by reading from stdin, using the argume= nt > >> '--from-files0=3D-', it reuses the same fstatus struct for each file. > >> > >> The problem is that the 'wc' function checks the 'failed' member of th= is > >> struct and if it is <=3D0, it skips doing fstat on the file. The main = loop > >> doesn't reset this value between files, so only the first file has fst= at > >> 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 fil= es > >> when reading the file list from stdin. > > > > Ouch. This seems to be since v7.0-96-gc2e56e0 > > It would also mean there would be a lot of redundant reading > > if the initial file was significantly smaller than any other file. > > > > $ truncate -s1G wc.big > > $ touch wc.small > > $ printf '%s\0' wc.big wc.small | wc -c --files0-from=3D- > > 1073741824 wc.big > > 1073741760 wc.small > > 2147483584 total > > Sorry for the delay. > I didn't go far enough back in my TODO list so missed this. > Proposed patch attached. > > thanks, > P=C3=A1draig > > --=20 Bill Fraser { http://www.codewise.org/wrf } --001a1141f99e9c5d79054408438e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Looks good :)

On Mon, Dec 19, 2016 at 11:00 AM, P=C3=A1draig Brady <P@= draigbrady.com> wrote:
On 21/03/16 15:16, P=C3=A1draig Brady wrote:
> On 21/03/16 00:59, William R. Fraser wrote:
>> When wc gets its list of files by reading from stdin, using the ar= gument
>> '--from-files0=3D-', it reuses the same fstatus struct for= each file.
>>
>> The problem is that the 'wc' function checks the 'fail= ed' member of this
>> struct and if it is <=3D0, it skips doing fstat on the file. Th= e 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.
>
> Ouch. This seems to be since v7.0-96-gc2e56e0
> It would also mean there would be a lot of redundant reading
> if the initial file was significantly smaller than any other file.
>
> $ truncate -s1G wc.big
> $ touch wc.small
> $ printf '%s\0' wc.big wc.small | wc -c --files0-from=3D-
> 1073741824 wc.big
> 1073741760 wc.small
> 2147483584 total

Sorry for the delay.
I didn't go far enough back in my TODO list so missed this.
Proposed patch attached.

thanks,
P=C3=A1draig




--
Bill Fraser {=C2=A0= http://www.codewi= se.org/wrf=C2=A0}
--001a1141f99e9c5d79054408438e-- From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 20 Dec 2016 01:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.148219863011484 (code B ref 23073); Tue, 20 Dec 2016 01:51:02 +0000 Received: (at 23073) by debbugs.gnu.org; 20 Dec 2016 01:50:30 +0000 Received: from localhost ([127.0.0.1]:48156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ9ZW-0002zA-3j for submit@debbugs.gnu.org; Mon, 19 Dec 2016 20:50:30 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:56795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ9ZU-0002yv-CP for 23073@debbugs.gnu.org; Mon, 19 Dec 2016 20:50:28 -0500 Received: from [192.168.101.10] ([217.86.72.253]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Ltj6n-1cktCb3LyX-011EbD; Tue, 20 Dec 2016 02:50:20 +0100 References: <56F01053.4030605@draigBrady.com> From: Bernhard Voelker Message-ID: <61102355-1692-72c4-0f65-0cc608e5fb1a@bernhard-voelker.de> Date: Tue, 20 Dec 2016 02:50:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:96vrqLX9EeUbi2drrbK+5w5gsXjld4CqAN9oJTX0Fay05Q+/4vT OA89/iAXXYxrffdYT0htVmrGA7pFmdc7UyOSJXG/zvmOEFtyjWVDR2pPU9mjIOJgGlQDxSA fIi34coylGU49VrFZvm+LXs9HgQ9DEqHRObhTjOj2OqafBx3+LZ/2VOFmuhc2bvjoddBlG2 4tpCHAYTI9Bzx9GwMzCBQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:pI9F+fXmf70=:f88cUTVETK//gpHGqsv6Uc XqZovOjN6WNae176AFQbTFKVDLGKh+BUdKEAC40wqpgwU1pJLFAEdOfteWX1wsSGOUtPPEGTO F+X08ErTN+OVCPqtwAMuZzz8RdjbwBLWxljfPXf7gRFDsGKyzbuAUWrpgdaNTCoefCe7Go65w rF+3cgFieOPDgAyGLqFb2hNhEvVS6axqwN2EKsIUiO4Sm/dloWfzMURA86aPCuBA0ONO0mWye nSF/S/VpbQRw98FAMqVtGXN0eVtffGnrc1ALYMmNYD7VeTIK6qQy6GeVZUy4SERhpJo/bBvjN 373yc41zY5D09OPzr1W1js5KkgJDFjIUeYakoS4XdsC41oIwqGgG+eUVz65/Ouf+uFQmiLIrX /NlkKSBxc3rcPHT/ex2QtDQ0egXQg/BUbUr5eAJtgena0u4DKY0ZYhnrDl/e+FdyjJu39P49C r477gDh3m6Fkf0+/GyY+RYMpNQRreYPx2Eun9XqoiZkQMxTCrOAJGOLJLHd+9O4ZnD9um9wfP Xfyclhr7KmA+3Oqy/tt37aPqJwZlAA0H9rxLucVTyFru7l5GpS60nLIJYkDgM0Z2F6NOMqKt2 vtJh9IoVF9dAnDH4/z5UBVdpPPWVzXWNbiqMK/Nl4525JLInuW/pVk2o2rzwcQ7xpBWHg9nxv U9DMMSbLRGiKnQ2aEMuUiMH/BHsgkscMvfhDhPsE/kY/Q70m3W5CLr+PL1Nm70LkkTgCuGYOc RzCuoiQKRMbkXdYt X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 12/19/2016 08:00 PM, Pádraig Brady wrote: > + [bug introduced in coreutils-7.1] FWIW I think that the bug was not introduced in v7.0-96-gc2e56e0: I had a working 8.23 on a system here, so I took the time to search deeper. I found the reason to be the wrong value of the 'hi_pos' parameter passed to lseek(): open("wc.big", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=1073741824, ...}) = 0 lseek(3, 1073741824, SEEK_CUR) = 1073741824 read(3, "", 16384) = 0 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 8), ...}) = 0 write(1, "1073741824 wc.big\n", 181073741824 wc.big) = 18 close(3) = 0 open("wc.small", O_RDONLY) = 3 lseek(3, 1073741824, SEEK_CUR) = 1073741824 read(3, "", 16384) = 0 write(1, "1073741824 wc.small\n", 201073741824 wc.small This took me directly to v8.23-47-g2662702 (which a quick test against v8.23-47-g2662702^ confirmed). Therefore, I think it's worth to do the following amendment: - [bug introduced in coreutils-7.1] + [bug introduced in coreutils-8.24] Thanks & have a nice day, Berny From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 20 Dec 2016 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bernhard Voelker , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.148223952832021 (code B ref 23073); Tue, 20 Dec 2016 13:13:02 +0000 Received: (at 23073) by debbugs.gnu.org; 20 Dec 2016 13:12:08 +0000 Received: from localhost ([127.0.0.1]:48335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJKD9-0008KP-Q8 for submit@debbugs.gnu.org; Tue, 20 Dec 2016 08:12:07 -0500 Received: from midir.magicbluesmoke.com ([82.195.144.46]:57892 helo=mail.magicbluesmoke.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJKD7-0008KF-B2 for 23073@debbugs.gnu.org; Tue, 20 Dec 2016 08:12:05 -0500 Received: from [192.168.1.80] (unknown [109.79.94.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id A7D81242; Tue, 20 Dec 2016 13:12:02 +0000 (GMT) References: <56F01053.4030605@draigBrady.com> <61102355-1692-72c4-0f65-0cc608e5fb1a@bernhard-voelker.de> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <085ef657-301a-e63f-e74c-f55a325b5fce@draigBrady.com> Date: Tue, 20 Dec 2016 13:12:02 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <61102355-1692-72c4-0f65-0cc608e5fb1a@bernhard-voelker.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 20/12/16 01:50, Bernhard Voelker wrote: > On 12/19/2016 08:00 PM, Pádraig Brady wrote: >> + [bug introduced in coreutils-7.1] > > FWIW I think that the bug was not introduced in v7.0-96-gc2e56e0: > I had a working 8.23 on a system here, so I took the time to search deeper. > I found the reason to be the wrong value of the 'hi_pos' parameter passed > to lseek(): > > open("wc.big", O_RDONLY) = 3 > fstat(3, {st_mode=S_IFREG|0644, st_size=1073741824, ...}) = 0 > lseek(3, 1073741824, SEEK_CUR) = 1073741824 > read(3, "", 16384) = 0 > fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 8), ...}) = 0 > write(1, "1073741824 wc.big\n", 181073741824 wc.big) = 18 > close(3) = 0 > open("wc.small", O_RDONLY) = 3 > lseek(3, 1073741824, SEEK_CUR) = 1073741824 > read(3, "", 16384) = 0 > write(1, "1073741824 wc.small\n", 201073741824 wc.small > > This took me directly to v8.23-47-g2662702 (which a quick test > against v8.23-47-g2662702^ confirmed). > > Therefore, I think it's worth to do the following amendment: > > - [bug introduced in coreutils-7.1] > + [bug introduced in coreutils-8.24] Right! While st_size would have been incorrect for subsequent files since v7.1, it was only used since v8.24. Fixed with: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=94d2c68 thanks, Pádraig From unknown Fri Aug 22 01:04:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23073: wc reports wrong byte counts when using '--from-files0=-' Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 20 Dec 2016 13:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23073 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 23073@debbugs.gnu.org Received: via spool by 23073-submit@debbugs.gnu.org id=B23073.14822408831905 (code B ref 23073); Tue, 20 Dec 2016 13:35:02 +0000 Received: (at 23073) by debbugs.gnu.org; 20 Dec 2016 13:34:43 +0000 Received: from localhost ([127.0.0.1]:48341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJKZ1-0000Uf-Nu for submit@debbugs.gnu.org; Tue, 20 Dec 2016 08:34:43 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:61864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJKZ0-0000UR-22 for 23073@debbugs.gnu.org; Tue, 20 Dec 2016 08:34:42 -0500 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LqCzQ-1coFXG1d44-00dkCf; Tue, 20 Dec 2016 14:34:34 +0100 References: <56F01053.4030605@draigBrady.com> <61102355-1692-72c4-0f65-0cc608e5fb1a@bernhard-voelker.de> <085ef657-301a-e63f-e74c-f55a325b5fce@draigBrady.com> From: Bernhard Voelker Message-ID: <54eb98a5-3414-8f18-8c72-02ed731d1fd8@bernhard-voelker.de> Date: Tue, 20 Dec 2016 14:34:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <085ef657-301a-e63f-e74c-f55a325b5fce@draigBrady.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:gePwPDnJuJjO8C2rNH1CH9vo6aH56lr05yVNNElyiNLLDrEQ4CV +l/k/HgmHdoAtBsL2K4YqaRWgzvH5MdCLP0POmofLqe3J1UkbsehtWuLJuCv3dkwAzTKVl+ zgx0QlTDw8OoZDb/0icMLd+HuPTjeGHZX7Y5EAgg233KMj1cMSGNK+CtzJZMI+un86pnMca Mc+6JaabXIu34MXgW0hPg== X-UI-Out-Filterresults: notjunk:1;V01:K0:P0rjtxyjSPw=:XKoKNTiAal5QkFVSj8q5R1 dAIHS4MhK1dtDbpig/VobI4Jsk2+2egjYTDAn5I0lz9GVJDPBV3hS8mhES9DrXuUoN7+HBjsj +oSMn0eFijkQ2oaNz854Y5JCDUt3JgWOLwLi/ROFFs0b36DTTm/BplEo8hG7TbeAp7cEhelyq JuI7SSm1upVFsSiG3l7B3o3qhADqOnuqTn38ucR5nmy4zPGzLJUocdWuR2r8AonHhqbKA8sg8 /IZoiOzzgm5qZxwUidcTOv7mAbhkervl9+NIY5mPKFwbobN33TCw1cDPozKwcEGyoHz6wPAL0 P8xpBh//9Arpd+u0pC6Vf/LP2G67Sa3TU7Awaf7MyloGuUB5E6+UyXeJTe68F2T3GEeMV2lVl RW2T4R6j/gQaTbdvrj1wx6akRF7Y+QQmhHo68F4FFecp9144efpotlQMuchJgDeCAaBQoGrzq LsT3rSoQNBmeHj1PRO+4t8sisAQPse5YYT3RU4OCGUGOs1JFxSwnpmSae7187HPRELY6iUEuu c5jgR7YeWVGxbyueS96KRcHfWrxPvQdTUsBrhjcpA/H7s0w96K+P3gCbrSnar0ucGuwwTvTfz zVomGJe9vnQTeJXmrTqJ9M5w5WP6aWnSzCjex5m1lFQFgo3u9KnzIMOmOJWI7Wm0xCraX9ZXv hI5pJ92OKhUhjPtauMIlzXrhbbSp+neNCOLD/FOJytXf3/izxqRtR/AGpISo9uOFXhu+b+y2w E52SU/1tI8PPm5QZ X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 12/20/2016 02:12 PM, Pádraig Brady wrote: > Right! > > While st_size would have been incorrect for subsequent > files since v7.1, it was only used since v8.24. > > Fixed with: > http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=94d2c68 Thanks! Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 25 12:11:18 2018 Received: (at control) by debbugs.gnu.org; 25 Oct 2018 16:11:18 +0000 Received: from localhost ([127.0.0.1]:42755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFiE9-0006qR-PV for submit@debbugs.gnu.org; Thu, 25 Oct 2018 12:11:17 -0400 Received: from mail-it1-f171.google.com ([209.85.166.171]:38827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFiE7-0006qE-VK for control@debbugs.gnu.org; Thu, 25 Oct 2018 12:11:16 -0400 Received: by mail-it1-f171.google.com with SMTP id i76-v6so2455354ita.3 for ; Thu, 25 Oct 2018 09:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:mime-version:content-disposition:user-agent; bh=NWADbyx/8H2XdpUfQa8g0CT53CpSgnPJAFWy/kZyTH8=; b=hRNrPqgKXa5XHVSvoPkSdSGCF1n9x9iY3h1H8ibnt0TXGYScNeBuHPfPNMT9HZvmiK gPuqqPk8YvPFQ/p3oMx6xWd6DlJr3DatiNz3sN9ai+RODvgeNWJYrCgEwRMHkWh907bJ 0zbjGRT+1CC9kDfJ3ymV/vaUpBdxT9aUsX05MKO8ShHzI9TcKvtYYtGdjkcZL4IbfjAP kEMpETVmXYeg7r8rROdbOHjsaVvlFP3A03pdO64L/8lhybVnQUPgpIEoDbIMFfowUA97 lXzNY9CTbgfQF8Jbt1oBNcEjE8Eq8GKrIfyb78j2ZeZs+WCyV1LeXzsqc5RjSt0DqPPn jBhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:message-id:mime-version :content-disposition:user-agent; bh=NWADbyx/8H2XdpUfQa8g0CT53CpSgnPJAFWy/kZyTH8=; b=rk/v/hstOgGod0B9aUU+sAY7Z+ualKXoUCprDa9Y/75Z2VuyjMUcDh1Y+HQkwAvmUd R+4HgfEohCmvVyI3oet+tk44fZdJqgxWWH58Fm52k9uuz9Kvt69JtVUj9cOQsdKZZA9i hwbp307sKshNu6XgPSwlxgQjT+8w0BPZh7ilXvaEARNLBKMEGa2JAn14ZoJ8dloGKVET ngUNc3DB4K8g2W0Yxng910F07ss2O8wn/3seZFkxSE/fhjqSlKvIlQZdhldZwgbhXlB2 lVFEUYPthMjhIk0Te4E1dOZmXo7bEQVXZ3wptuUXapFVpaBO+omR0/u8H906AV4FQbRM bldQ== X-Gm-Message-State: AGRZ1gIm4oeVVNsxkoVaGqnLWf8D+QR0DhVYCekDsLKpbX3WTOdKqiy9 K8Vojc43iqQSGLvwE8krPezrP51Kw2I= X-Google-Smtp-Source: AJdET5fZx6RTaDWzt5XVg2dMqzNj7QmRgFZwDVpBiREOrN8nPUvwVJHDBcpEyFIFOiTzG+44a4lB+w== X-Received: by 2002:a24:2993:: with SMTP id p141-v6mr1437546itp.119.1540483869818; Thu, 25 Oct 2018 09:11:09 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.gmail.com with ESMTPSA id q205-v6sm1895430itc.2.2018.10.25.09.11.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Oct 2018 09:11:08 -0700 (PDT) Date: Thu, 25 Oct 2018 10:11:05 -0600 From: Assaf Gordon To: control@debbugs.gnu.org Message-ID: <20181025161105.xvxadcrsfugtl33i@tomato.housegordon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 23073 fixed close 23073 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.171 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.166.171 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) tags 23073 fixed close 23073