busybox/sysklogd
Grant Erickson fc466720b5 syslogd: Fix 'OPT_locallog' check regression in 'syslogd_main'
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'.

Fixes: 02378ce20c ("syslogd: decrease stack usage, ~50 bytes")

function                                             old     new   delta
syslogd_init                                        1140    1137      -3

Signed-off-by: Grant Erickson <gerickson@nuovations.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-04-08 16:14:34 +02:00
..
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
Kbuild.src sysklogd/*: convert to new-style "one file" applets 2015-10-18 22:40:09 +02:00
klogd.c Update applet size estimates 2023-07-10 17:25:21 +02:00
logger.c Update applet size estimates 2023-07-10 17:25:21 +02:00
logread.c Update applet size estimates 2023-07-10 17:25:21 +02:00
syslogd.c syslogd: Fix 'OPT_locallog' check regression in 'syslogd_main' 2025-04-08 16:14:34 +02:00
syslogd_and_logger.c use gmtime_r() instead of gmtime() 2018-03-06 18:11:47 +01:00