render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From df25234304fb6ec02e20df31956946df53a3d941 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <df25234304fb6ec02e20df31956946df53a3d941.1375465853.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Fri, 2 Aug 2013 12:15:57 +0100
43fe83
Subject: [PATCH] Avoid crash if NULL is passed for filename/funcname in
43fe83
 logging
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=991348
43fe83
43fe83
The journald code would crash if a NULL was passed for the
43fe83
filename / funcname in the logging code. This shouldn't
43fe83
happen in general, but it is better to be safe, since there
43fe83
have been bugs triggering this.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit b4ca2999020ab4adf7a73ccbff1de2b40a097874)
43fe83
---
43fe83
 src/util/virlog.c | 6 ++++--
43fe83
 1 file changed, 4 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/util/virlog.c b/src/util/virlog.c
43fe83
index d1fb0b3..047a131 100644
43fe83
--- a/src/util/virlog.c
43fe83
+++ b/src/util/virlog.c
43fe83
@@ -1181,9 +1181,11 @@ virLogOutputToJournald(virLogSource source,
43fe83
     journalAddInt(&state, "PRIORITY", priority);
43fe83
     journalAddString(&state, "LIBVIRT_SOURCE",
43fe83
                      virLogSourceTypeToString(source));
43fe83
-    journalAddString(&state, "CODE_FILE", filename);
43fe83
+    if (filename)
43fe83
+        journalAddString(&state, "CODE_FILE", filename);
43fe83
     journalAddInt(&state, "CODE_LINE", linenr);
43fe83
-    journalAddString(&state, "CODE_FUNC", funcname);
43fe83
+    if (funcname)
43fe83
+        journalAddString(&state, "CODE_FUNC", funcname);
43fe83
 
43fe83
     memset(&sa, 0, sizeof(sa));
43fe83
     sa.sun_family = AF_UNIX;
43fe83
-- 
43fe83
1.8.3.2
43fe83