From: Zbigniew Jędrzejewski-Szmek Date: Thu, 6 Oct 2022 11:07:49 +0000 (+0200) Subject: basic/log: include the log syntax callback in the errno protection block X-Git-Tag: v252-rc2~70^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b7834fe5de3de690e6efb9467c61691c4b2f30f;p=thirdparty%2Fsystemd.git basic/log: include the log syntax callback in the errno protection block In general, log_syntax_internal() must keep errno unchanged. But the call to log_syntax_callback() was added outside of the block protected by PROTECT_ERRNO. --- diff --git a/src/basic/log.c b/src/basic/log.c index c5e16d669b0..2f5353c739d 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1341,18 +1341,19 @@ int log_syntax_internal( const char *func, const char *format, ...) { + PROTECT_ERRNO; + if (log_syntax_callback) log_syntax_callback(unit, level, log_syntax_callback_userdata); - PROTECT_ERRNO; - char buffer[LINE_MAX]; - va_list ap; - const char *unit_fmt = NULL; - if (_likely_(LOG_PRI(level) > log_max_level) || log_target == LOG_TARGET_NULL) return -ERRNO_VALUE(error); + char buffer[LINE_MAX]; + va_list ap; + const char *unit_fmt = NULL; + errno = ERRNO_VALUE(error); va_start(ap, format);