opnsense-src/usr.bin/tail
Dag-Erling Smørgrav 7441705cae tail: Fix heap overflow in -F case.
The number of events we track can vary over time, but we only allocate
enough space for the exact number of events we are tracking when we
first begin, resulting in a trivially reproducable heap overflow.  Fix
this by allocating enough space for the greatest possible number of
events (two per file) and clean up the code a bit.

Also add a test case which triggers the aforementioned heap overflow,
although we don't currently have a way to detect it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D42839

(cherry picked from commit 621f45532c5887c96b708ce232c52878d0053325)

tail: Clean up error messages.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42842

(cherry picked from commit b70e57be2cfe83ec9f410e2f317ea38aaac61a98)
2023-12-13 17:41:48 +01:00
..
tests tail: Fix heap overflow in -F case. 2023-12-13 17:41:48 +01:00
extern.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
forward.c tail: Fix heap overflow in -F case. 2023-12-13 17:41:48 +01:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend.options Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
misc.c Remove $FreeBSD$: two-line .c pattern 2023-08-16 11:54:34 -06:00
read.c tail: Fix heap overflow in -F case. 2023-12-13 17:41:48 +01:00
reverse.c tail: Fix heap overflow in -F case. 2023-12-13 17:41:48 +01:00
tail.1 tail.1: Add an example for +n 1 2023-12-01 12:19:04 +01:00
tail.c tail: Fix heap overflow in -F case. 2023-12-13 17:41:48 +01:00