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