Skip to content

Commit

Permalink
syslogd: Fix issues reported by gcc
Browse files Browse the repository at this point in the history
- When forwaring a message, don't assume that f->f_num_addr_fds > 0.
- Avoid calling free() on a stack-allocated object.

Fixes:	4ecbee2 ("syslogd: Open forwarding socket descriptors")
Fixes:	f4b4a10 ("syslogd: Move selector parsing into its own function")

Reviewed by:	jfree
Differential Revision:	https://reviews.freebsd.org/D47844
  • Loading branch information
markjdb committed Nov 30, 2024
1 parent c296ac7 commit fe29114
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions usr.sbin/syslogd/syslogd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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;
Expand Down

0 comments on commit fe29114

Please sign in to comment.