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)
Thu, Nov 7, 3:37 AM
Unknown Object (File)
Thu, Nov 7, 3:31 AM
Unknown Object (File)
Thu, Nov 7, 3:28 AM
Unknown Object (File)
Thu, Nov 7, 3:28 AM
Unknown Object (File)
Thu, Nov 7, 1:28 AM
Unknown Object (File)
Oct 21 2024, 4:05 AM
Unknown Object (File)
Oct 21 2024, 4:05 AM
Unknown Object (File)
Oct 21 2024, 4:05 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 Skipped
Unit
Tests Skipped

Event Timeline

usr.sbin/syslogd/syslogd.c
2822–2823

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);
2901–2902

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

usr.sbin/syslogd/syslogd.c
2901–2902

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.