when rsyslog is HUPed immediately after startup and before it is fully
initialized, there is a potential race with the list of loaded modules.
This patch ensures no bad things can happen in that case.
Detected by LLVM TSAN, not seen in practice.
Signed-off-by: Rainer Gerhards <rgerhards@adiscon.com>
function modules add functions to rainerscript dynamically,
change http_request into such a module (enabled by default).
This module can be used as a sample for future function modules.
If the parameter "log.file" is specified, impstats writes its own
log file. However, HUP is not handled for this file, which makes
the functionality unusable with log rotation. It is also counter-
intuitive for users.
This patch enables correct HUP processing. As a sideline, it also
introduces a generic HUP processing framework for non-action type
of loadable modules.
closes https://github.com/rsyslog/rsyslog/issues/1662
closes https://github.com/rsyslog/rsyslog/issues/1663
These were very theoretic, and enven the potential memory
leak would not have any effect. Thus it was not tried to solve
initially. Doing it now primarily so that static analyzer is
happy.
Remove the use sizeof(char) or sizeof(uchar) in calculations for memory
allocation or string length. There are no known platforms for which
sizeof(char) or sizeof(uchar) is not 1, and c99 has defined sizeof(char)
to be 1 (section 6.5.3.4 of c99).
Error: CLANG_WARNING:
rsyslog-7.4.10/runtime/modules.c:1086:26: warning: Result of 'malloc' is converted to a pointer of type 'uchar', which is incompatible with sizeof operand type 'char'
rsyslog-7.4.10/runtime/rsyslog.h:441:34: note: expanded from macro 'CHKmalloc'
Error: CLANG_WARNING:
rsyslog-7.4.10/runtime/modules.c:1109:26: warning: Result of 'malloc' is converted to a pointer of type 'uchar', which is incompatible with sizeof operand type 'char'
rsyslog-7.4.10/runtime/rsyslog.h:441:34: note: expanded from macro 'CHKmalloc'
Error: RESOURCE_LEAK (CWE-772):
rsyslog-7.4.10/runtime/modules.c:394: alloc_fn: Storage is returned from allocation function "malloc(size_t)".
rsyslog-7.4.10/runtime/modules.c:394: var_assign: Assigning: "pNew" = storage returned from "malloc(32UL)".
rsyslog-7.4.10/runtime/modules.c:406: leaked_storage: Variable "pNew" going out of scope leaks the storage it points to.
If they did not support this, accidently the output module part of the
module union was written, leading to unpredictable results. Note: all
core modules do support this interface, but some contributed or very
old ones do not.