Page MenuHomeFreeBSD

syslogd: Move prop_filter allocation into function
ClosedPublic

Authored by jfree on Aug 8 2023, 3:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 9:39 PM
Unknown Object (File)
Mon, Apr 29, 9:43 PM
Unknown Object (File)
Apr 22 2024, 8:24 PM
Unknown Object (File)
Apr 10 2024, 4:28 PM
Unknown Object (File)
Apr 6 2024, 12:44 PM
Unknown Object (File)
Apr 2 2024, 2:38 PM
Unknown Object (File)
Mar 18 2024, 9:37 AM
Unknown Object (File)
Mar 2 2024, 5:08 PM
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.