From 30a5c6628dc0fccc61ee453e67cd050196daba1c Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 26 Nov 2021 06:02:49 +0100 Subject: [PATCH] Avoid NULL pointers to internal logit() function The logit() function winds up calling vfprintf(), GLIBC is friendly enough to check for NULL and replace segfault with "(null)", but other C-libs may not handle it as gracefully. Signed-off-by: Joachim Wiberg --- src/syslogd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index a4c00bc..ca857d3 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -1357,8 +1357,13 @@ static void logmsg(struct buf_msg *buffer) int fac, prilev; logit("logmsg: %s, flags %x, from %s, app-name %s procid %s msgid %s sd %s msg %s\n", - textpri(buffer->pri), buffer->flags, buffer->hostname, buffer->app_name, - buffer->proc_id, buffer->msgid, buffer->sd, buffer->msg); + textpri(buffer->pri), buffer->flags, + buffer->hostname ? buffer->hostname : "nil", + buffer->app_name ? buffer->app_name : "nil", + buffer->proc_id ? buffer->proc_id : "nil", + buffer->msgid ? buffer->msgid : "nil", + buffer->sd ? buffer->sd : "nil", + buffer->msg); /* Messages generated by syslogd itself may not have a timestamp */ check_timestamp(buffer);