Date: Sat, 3 Feb 2024 01:36:21 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 8e05c2373efd - main - wc: Do not use st_size if it equals zero Message-ID: <202402030136.4131aL3U010724@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8e05c2373efd43632b1ec410528552fa01b40a3f commit 8e05c2373efd43632b1ec410528552fa01b40a3f Author: Ricardo Branco <rbranco@suse.de> AuthorDate: 2024-02-03 00:05:05 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-03 01:34:59 +0000 wc: Do not use st_size if it equals zero Pseudo-filesystems often cannot compute the size of the file correctly and report 0 for the size. Ignore the size when it's zero and fallback to the size unknown code. PR: 276093 Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/985 --- usr.bin/wc/wc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index 7cb72212d1cb..76b65e5f870d 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -230,7 +230,8 @@ cnt(const char *file) (void)close(fd); return (1); } - if (S_ISREG(sb.st_mode)) { + /* pseudo-filesystems advertize a zero size */ + if (S_ISREG(sb.st_mode) && sb.st_size > 0) { reset_siginfo(); charct = sb.st_size; show_cnt(file, linect, wordct, charct, llct);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402030136.4131aL3U010724>