From 016bac89db9ce584b0a5980b119c35b9825ab0f8 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 28 Jun 2020 06:52:39 +0000 Subject: [PATCH] [fifolog] wrap the recno when we hit the end of the provided file size. Without this the log just keeps growing to infinity. Reviewed by: phk Differential Revision: https://reviews.freebsd.org/D25478 --- usr.sbin/fifolog/lib/fifolog_write_poll.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr.sbin/fifolog/lib/fifolog_write_poll.c b/usr.sbin/fifolog/lib/fifolog_write_poll.c index 4281e1b7d336..cffe095d4d7b 100644 --- a/usr.sbin/fifolog/lib/fifolog_write_poll.c +++ b/usr.sbin/fifolog/lib/fifolog_write_poll.c @@ -239,6 +239,14 @@ fifolog_write_output(struct fifolog_writer *f, int fl, time_t now) */ f->seq++; f->recno++; + + /* + * Ensure we wrap recno once we hit the file size (in records.) + */ + if (f->recno >= f->ff->logsize) + /* recno 0 is header; skip */ + f->recno = 1; + f->flag = 0; memset(f->obuf, 0, f->obufsize);