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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2021-11-26 06:02:49 +01:00
parent ac9749a240
commit 30a5c6628d

View File

@ -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);