Bug 276107 - [patch] tail(1) is not able to operate on files residing in pseudo-filesystems
Summary: [patch] tail(1) is not able to operate on files residing in pseudo-filesystems
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Xin LI
URL: https://github.com/freebsd/freebsd-sr...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-03 20:38 UTC by Ricardo Branco
Modified: 2024-01-06 22:34 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Branco 2024-01-03 20:38:37 UTC
tail(1) is not able to operate on files residing in pseudo-filesystems or others that advertise a zero size.

To reproduce: `tail -1 /compat/linux/proc/mounts` dumps the whole file.

Fix: https://github.com/freebsd/freebsd-src/pull/990
Comment 1 commit-hook freebsd_committer freebsd_triage 2024-01-04 09:01:47 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1fb3caee72241b9b4dacbfb0109c972a86d4401f

commit 1fb3caee72241b9b4dacbfb0109c972a86d4401f
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2024-01-03 20:32:47 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2024-01-04 09:00:23 +0000

    tail: Do not trust st_size if it equals zero.

    PR:             bin/276107
    MFC after:      1 week

 usr.bin/tail/forward.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 2 Xin LI freebsd_committer freebsd_triage 2024-01-04 09:04:41 UTC
Committed, thanks!
Comment 3 Marek Zarychta 2024-01-05 22:49:44 UTC
Please try instead: cat /compat/linux/proc/mounts | tail -1