]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
sysdeps-unix: Always initialize flags for syslog()
authorSimon McVittie <smcv@collabora.com>
Wed, 25 Sep 2024 13:40:16 +0000 (14:40 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 25 Sep 2024 13:42:15 +0000 (14:42 +0100)
If passed an invalid DBusSystemLogSeverity, the default case for the
switch construct is to crash out with an assertion failure, but the
assertion failure itself is not compiled in if we are doing a production
build without assertions.

Detected by compiling with gcc 14, which does some static analysis
by default.

Signed-off-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-sysdeps-unix.c

index a00676f4e354591e39140a981b4adbcb8b1a3870..59d4afcf64e0da81edbf799acec97b600f9e182c 100644 (file)
@@ -5222,7 +5222,7 @@ _dbus_logv (DBusSystemLogSeverity  severity,
 #ifdef HAVE_SYSLOG_H
   if (log_flags & DBUS_LOG_FLAGS_SYSTEM_LOG)
     {
-      int flags;
+      int flags = LOG_DAEMON | LOG_WARNING;
       switch (severity)
         {
           case DBUS_SYSTEM_LOG_INFO: