Page MenuHomeFreeBSD

syslogd: Move prop_filter allocation into function
ClosedPublic

Authored by jfree on Aug 8 2023, 3:37 PM.
Tags
None
Referenced Files
F132096809: D41373.id127955.diff
Mon, Oct 13, 3:59 PM
F132051494: D41373.id127955.diff
Mon, Oct 13, 6:09 AM
Unknown Object (File)
Sun, Sep 28, 1:41 AM
Unknown Object (File)
Fri, Sep 26, 1:32 AM
Unknown Object (File)
Tue, Sep 16, 7:37 AM
Unknown Object (File)
Aug 31 2025, 12:58 AM
Unknown Object (File)
Aug 30 2025, 9:53 PM
Unknown Object (File)
Aug 29 2025, 11:22 AM
Subscribers

Details

Summary
Clean up the cfline() function by moving the prop_filter memory
allocation into the prop_filter_compile() function.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.sbin/syslogd/syslogd.c
2851–2852

These frees are in the wrong order.

It'd be nicer to have a dedicated error path:

goto error;
...
error:
    free(pfilter->pflt_re); // pfilter is zero-initialized, and free(NULL) is fine.
    free(pfilter);
    return (NULL);
2930–2931

Why not move the strdup() into prop_filter_compile() as well?

usr.sbin/syslogd/syslogd.c
2930–2931

If you adopt this suggestion, D41378 is no longer needed.

This revision is now accepted and ready to land.Aug 11 2023, 2:57 PM

In prop_filter_compile(), the filter string pointer is modified so free()'ing it leads to unintended behavior. Save a filter_begpos pointer and free() that during cleanup.

This revision now requires review to proceed.Aug 21 2023, 10:43 PM
This revision is now accepted and ready to land.Aug 23 2023, 2:35 PM
This revision was automatically updated to reflect the committed changes.