]> git.ipfire.org Git - thirdparty/coreutils.git/commit
tail: don’t output more lines than requested
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 30 Jul 2025 14:49:14 +0000 (07:49 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Aug 2025 02:48:05 +0000 (19:48 -0700)
commitfee8859750fecde7e1446a7dd82edf0389e51f31
tree601b02f24e42936fe39dbe6dd7baab767c57162f
parenteb0086669fbc4d924772918b861a839dc3c1a5a9
tail: don’t output more lines than requested

* src/tail.c (file_lines): Fix an unlikely bug where ‘tail -n N’
could output more than N lines if standard input is a largish
regular file with large initial offset that starts with (say) N-1
lines after the initial offset, but grows to N+1 lines between the
fstat and read calls.  In this case ‘tail -n N’ now outputs N-1
lines, not N+1; that is, it pretends the file grew after ‘tail’
read it.  That is better than outputting more than N lines.
NEWS
src/tail.c