[PATCH] syslogd: Fix 'OPT_locallog' check regression in 'syslogd_main'.
Denys Vlasenko
vda.linux at googlemail.com
Tue Apr 8 14:19:19 UTC 2025
Applied, thank you
On Wed, Apr 2, 2025 at 5:16 AM Grant Erickson <gerickson at nuovations.com> wrote:
>
> In the recent refactoring of 'syslogd_main', a regression was
> introduced in handling the manual bitwise OR of 'OPT_locallog' as
> follows:
>
> if (ENABLE_FEATURE_REMOTE_LOG && !(opts & OPT_remotelog)) // -R
> option_mask32 |= OPT_locallog;
>
> 'opts' represents the locally-scoped output of 'getopt32' and
> 'option_mask32' represents the globally-scoped state of the
> same. Consequently, the above performs a bitwise OR to include
> 'OPT_locallog' of the globally-scoped option state, which 'opts' will
> not reflect locally.
>
> Manipulating the global, rather than local, state is correct as
> 'timestamp_and_log_internal' will later need to check 'OPT_locallog'.
>
> However, when the aforementioned refactor occurred, the following
> regressing change was made:
>
> - if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
> + if (!ENABLE_FEATURE_REMOTE_LOG || (opts & OPT_locallog)) {
>
> breaking the spatially- and temporally-removed check in
> 'timestamp_and_log_internal'.
>
> This returns the check in 'syslogd_main' to using the global
> 'option_mask32' state.
>
> Fixes: 02378ce20c6d2 ("syslogd: decrease stack usage, ~50 bytes”)
> Signed-off-by: Grant Erickson <gerickson at nuovations.com>
>
> ---
> sysklogd/syslogd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
> index 7558051f0e7f..fa03aa28093b 100644
> --- a/sysklogd/syslogd.c
> +++ b/sysklogd/syslogd.c
> @@ -1179,7 +1179,7 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv)
> }
> }
> #endif
> - if (!ENABLE_FEATURE_REMOTE_LOG || (opts & OPT_locallog)) {
> + if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
> recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */
> split_escape_and_log(recvbuf, sz);
> }
> --
> 2.45.0
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> https://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list