332600 |
16-Apr-2018 |
asomers |
MFC r329606:
tail: fix "tail -r" for piped input that begins with '\n'
A subtle logic bug, probably introduced in r311895, caused tail to print the first two lines of piped input in forward order, if the very first character was a newline.
PR: 222671 Reported by: Jim Long <freebsd-bugzilla@umpquanet.com>, pprocacci@gmail.com Sponsored by: Spectra Logic Corp |
332482 |
13-Apr-2018 |
kevans |
MFC r332372-r332374: tail(1)/head(1) compatibility long options
r332372: tail(1): Add some long options
Add --blocks, --bytes, and --lines long options for -b, -c, and -n respectively. This improves tail(1)'s compatibility with its GNU counterpart in a straightforward way.
r332373: tail(1): Address mandoc concern (space before punctuation after macro)
r332374: head(1): Provide long options
Provide long options --bytes and --lines to match -c and -n respectively. This improves head(1)'s compatibility with its GNU counterpart in a sensible way. |
314427 |
28-Feb-2017 |
asomers |
MFC r311572, r311895, r311928, r311985, r312395, r312417
r311572: Fix file descriptor leaks in cmp(1)
Also, add a few test cases
Reported by: Coverity CID: 271624 275338 Reviewed by: ngie MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9074
r311895: Fix memory leaks during "tail -r" of an irregular file
* Rewrite r_buf to use standard tail queues instead of a hand-rolled circular linked list. Free dynamic allocations when done. * Remove an optimization for the case where the file is a multiple of 128KB in size and there is a scarcity of memory. * Add ATF tests for "tail -r" and its variants.
Reported by: Valgrind Reviewed by: ngie MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9067
r311928: Fix build of usr.bin/tail with GCC
Submitted by: pluknet Reported by: pluknet MFC after: 27 days X-MFC-with: 311895 Sponsored by: Spectra Logic Corp
r311985: Fix uninitialized variable CIDs in route6d
The variables in question are actually return arguments, but it's still good form to initialize them.
Reported by: Coverity CID: 979679 979680 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r312395: Fix several Coverity CIDs in devd
CID 1362055, 1362054: File descriptor leaks during shutdown CID 1362013: Potential null-termination fail with long network device names CID 1362097: Uncaught exception during memory pressure CID 1362017, 1362016: Unchecked errors, possibly resulting in weird behavior if two devd instances start at the same time. CID 1362015: Unchecked error that will probably never fail
Reported by: Coverity CID: 1362055 1362054 1362013 1362097 1362017 1362016 1362015 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r312417: Fix build of devd with GCC 4.2
Reported by: olivier Pointy-hat-to: asomers MFC after: 27 days X-MFC-with: 312395 Sponsored by: Spectra Logic Corp |
313100 |
02-Feb-2017 |
asomers |
MFC r311160, r311210, r311288, r311292, r311298, r311340
r311160: misc minor fixes in mpr(4)
sys/dev/mpr/mpr_sas.c * Fix a potential null pointer dereference (CID 1305731) * Check for overrun of the ccb_scsiio.cdb_io.cdb_bytes buffer (CID 1211934)
sys/dev/mpr/mpr_sas_lsi.c * Nullify a dangling pointer in mprsas_get_sata_identify * Fix a memory leak in mprsas_SSU_to_SATA_devices (CID 1211935)
Reported by: Coverity (partially) CID: 1305731 1211934 1211935 Reviewed by: slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8880
r311210: Quell Coverity for diskinfo(8)
* CID 1198994: Don't run the speed disk on a disk with no sectors * CID 1011442: Don't call close(2) if open(2) fails * CID 1011161: Use snprintf instead of sprintf * CID 1009825: Check the return value of lseek
Reported by: Coverity CID: 1198994 1011442 1011161 1009825 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r311288: Delete dead code in chat(8)
It's always been dead, ever since first import in 1994. It's still dead in OpenBSD's version, too.
Reported by: Coverity CID: 270586 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r311292: Remove dead code in rpc_parse.c
It's been dead ever since it was imported from TI-RPC in 1995. The dead code is still present in Illumos today, but was removed from NetBSD in 2006.
Reported by: Coverity CID: 270097 Obtained from: NetBSD MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r311298: Remove dead code in dhclient(8)
The offending code has been dead ever since the import from OpenBSD in r195805. OpenBSD later deleted that entire function.
Reported by: Coverity CID: 500059 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
r311340: Misc Coverity fixes for tail(1)
CID 1006402: Initialize stack variable CID 271580: Don't leak memory when ENOMEM.
Reported by: Coverity CID: 271580 1006402 MFC after: 4 weeks Sponsored by: Spectra Logic Corp |
224865 |
14-Aug-2011 |
jilles |
tail: Fix crash if -F'ed file's filesystem disappears.
If tail notices that a file it is following no longer exists (because stat() fails), it will output any final lines and then close the file. If the read operation also causes an error, such as when the filesystem is forcefully unmounted, it closes the file as well, leading to fclose(NULL) and a segmentation fault.
PR: bin/159750 Submitted by: swills Approved by: re (kib) MFC after: 1 week
|
173838 |
22-Nov-2007 |
avatar |
Nuking the temporary pointer once it is properly tracked in local storage. This should fix the double free() bug where there's no tailing newline(\n) character:
current# echo -n test | tail testAssertion failed: (run->magic == ARENA_RUN_MAGIC), function arena_dalloc, file /usr/src/lib/libc/stdlib/malloc.c, line 2448. Abort (core dumped)
Reviewed by: kib MFC after: 3 days
|
163587 |
21-Oct-2006 |
marcel |
Better handle the -F case: o When stat(2) fails (i.e. the file has been moved) there's no new file with the same name yet, so keep showing the file that's open. This yields the same behaviour as -f, for which we don't stat(2). o When a new file with the same name has been created (i.e stat(2) succeeds but the inode or device numbers differ from the opened file), show any new lines in the opened file (i.e. the old or rotated file) before reopening the new file.
These changes fix the observed behaviour that tail(1) doesn't show the very last lines of the rotated (log) files.
PR: bin/101979 Tested by: Jos Backus <jos@catnook.com> MFC after: 2 months
|
141279 |
04-Feb-2005 |
delphij |
Save last displayed file by having the "last" pointer global and save it during we show the first file's tail. Instead of:
tarsier% tail -f 1 2 ==> 1 <== foo bar
==> 2 <== bar foo
==> 2 <== bar2 foo2
Now with this change, we have:
tarsier% tail -f 1 2 ==> 1 <== foo bar
==> 2 <== bar foo bar2 foo2
While I'm there, move a comment to where it should belong to. Also, const'ify the "last" static because we will never need to change the contents it points to.
MFC After: 1 week
|
118900 |
14-Aug-2003 |
dg |
Removed check of st_rdev changing in the -F support. st_rdev for regular files is usually the first direct block pointer. Since FreeBSD does automatic block reallocation to reduce filesystem fragmentation, the file being tailed can be relocated to different blocks 'on-the-fly', making the check for st_rdev unreliable. The result of this bug is tail -F pseudo-randomnly thinking the file was rotated when it wasn't, and as a result, spews out the entire file trying to catch up.
MFC after: 3 days
|
86888 |
25-Nov-2001 |
iedowse |
Since kqueue support was added to tail, the "-F" option (check for renames/rotations) only detected cases where the file itself was moved or deleted. If part of the path to the file (or a symlink in the path) was changed instead, tail would not notice.
Fix this by ensuring that we stat the path at least once every second in the -F case to check for changes. We still use kqueue when possible to inform us quickly when the file has changed.
PR: bin/24955 Submitted by: Maxim Konovalov <maxim@macomnet.ru> MFC after: 1 week
|
82762 |
01-Sep-2001 |
ache |
File positions are off_t nowdays, not long, so: long -> off_t strtol -> strtoll fseek -> fseeko
NOTE: that fseek not works for >long offsets files per POSIX:
[EOVERFLOW] For fseek( ), the resulting file offset would be a value which cannot be represented correctly in an object of type long.
|
74885 |
27-Mar-2001 |
ache |
Restore part of my fix spammed in v1.23: fseeko(file_size, SEEK_SET) -> fseek(0L, SEEK_END) 1) File may grows between operations, so fseeko to file_size may miss 2) 0L, SEEK_END is the same code using in tail in all other places
|
74827 |
26-Mar-2001 |
ache |
rlines() checks: 1) really check for size overflow by checking negative value. 2) since mmap() not support files over INT_MAX size, add check for it until either mmap() will be fixed or tail will be rewritted to handle large files alternatively. 3) replace fseek(... file_size, SEEK_SET) with fseek(... 0L, SEEK_END) to avoid off_t -> long cast 4) Use exit() if file is too big instead of warning and wrong logic afterwards.
|
61964 |
22-Jun-2000 |
jlemon |
If the kevent() registration fails (probably due to the underlying filesystem not being kq-aware), then fall back to using sleep. This allows tail to work with NFS filesystems again without chewing up CPU time.
When given the -F flag, resort to sleep/stat after the file was moved or deleted. This allows a window where the file being tailed does not exist at all, which is typically the case during log rotation. Switch back to using kq (if possible) after the file is reopened.
|
48792 |
12-Jul-1999 |
nik |
Add $Id$, to make it simpler for members of the translation teams to track.
The $Id$ line is normally at the bottom of the main comment block in the man page, separated from the rest of the manpage by an empty comment, like so;
.\" $Id$ .\"
If the immediately preceding comment is a @(#) format ID marker than the the $Id$ will line up underneath it with no intervening blank lines. Otherwise, an additional blank line is inserted.
Approved by: bde
|
17821 |
25-Aug-1996 |
peter |
Fix some bogons: - timeval in select loop was depending on not having the remaining time returned from select(), causing a busy spin on an implementation that does implement it. - the err() usage was pretty bogus, some of the error messages had strerror attached manually and then reattached by err().
|