From fe291141486acf27ed1c8eed791ba9897f84c3f0 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 29 Nov 2024 19:43:42 +0000 Subject: [PATCH] syslogd: Fix issues reported by gcc - When forwaring a message, don't assume that f->f_num_addr_fds > 0. - Avoid calling free() on a stack-allocated object. Fixes: 4ecbee2760f7 ("syslogd: Open forwarding socket descriptors") Fixes: f4b4a10abb26 ("syslogd: Move selector parsing into its own function") Reviewed by: jfree Differential Revision: https://reviews.freebsd.org/D47844 --- usr.sbin/syslogd/syslogd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 0e063b72beb639..23ef5d78c319d6 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1795,6 +1795,7 @@ fprintlog_write(struct filed *f, struct iovlist *il, int flags) iovlist_truncate(il, MaxForwardLen); #endif + lsent = 0; for (size_t i = 0; i < f->f_num_addr_fds; ++i) { struct msghdr msg = { .msg_iov = il->iov, @@ -2941,7 +2942,6 @@ parse_selector(const char *p, struct filed *f) pri = decode(buf, prioritynames); if (pri < 0) { dprintf("unknown priority name \"%s\"", buf); - free(f); return (NULL); } } @@ -2965,7 +2965,6 @@ parse_selector(const char *p, struct filed *f) i = decode(buf, facilitynames); if (i < 0) { dprintf("unknown facility name \"%s\"", buf); - free(f); return (NULL); } f->f_pmask[i >> 3] = pri;