]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/log: include the log syntax callback in the errno protection block
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Oct 2022 11:07:49 +0000 (13:07 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Oct 2022 14:25:56 +0000 (16:25 +0200)
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.

src/basic/log.c

index c5e16d669b0716b99a793dda015e342b46be70b9..2f5353c739d81470b3b9cce17cf5baef2980d459 100644 (file)
@@ -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);