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)
Tue, Aug 4, 9:07 AM
Unknown Object (File)
Tue, Aug 4, 7:05 AM
Unknown Object (File)
Tue, Aug 4, 2:46 AM
Unknown Object (File)
Mon, Aug 3, 5:06 PM
Unknown Object (File)
Mon, Aug 3, 2:59 PM
Unknown Object (File)
Mon, Aug 3, 6:07 AM
Unknown Object (File)
Sun, Jul 26, 5:59 AM
Unknown Object (File)
Sat, Jul 25, 5:29 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.