]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: fix non-literal string used in printf 5774/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Apr 2017 18:28:19 +0000 (14:28 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 21 Apr 2017 17:39:50 +0000 (13:39 -0400)
This was exposed by the previous commit. This could be potentially
unpleasant, but we are saved by the fact that this code path was only
taken for journald crashes, where we control COMM and know that it doesn't
contain any special characters. Use log_dispatch which does not do any
format processing to push the message out.

src/coredump/coredump.c

index 5828e949e3d48888459c0acb79d0d8002e1b800d..e9ada8e6dbe1d33ff3332cfad8316ae4059fc5ed 100644 (file)
@@ -800,12 +800,11 @@ log:
         if (journald_crash) {
                 /* We cannot log to the journal, so just print the MESSAGE.
                  * The target was set previously to something safe. */
-                log_struct(LOG_ERR, core_message, NULL);
+                log_dispatch(LOG_ERR, 0, core_message);
                 return 0;
         }
 
-        if (core_message)
-                IOVEC_SET_STRING(iovec[n_iovec++], core_message);
+        IOVEC_SET_STRING(iovec[n_iovec++], core_message);
 
         if (truncated)
                 IOVEC_SET_STRING(iovec[n_iovec++], "COREDUMP_TRUNCATED=1");