Avoid NULL pointer to vsnprintf()

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-22 04:27:18 +01:00
parent 558caf1a10
commit 1018d4a7f4

View File

@ -1698,9 +1698,12 @@ void fprintlog_write(struct filed *f, struct iovec *iov, int iovcnt, int flags)
f->f_prevcount = 0;
}
#define fmtlogit(bm) logit("%s(%d, 0x%02x, %s, %s, %s, %s, %s, %s)", __func__, \
bm->pri, bm->flags, bm->hostname, bm->app_name, \
bm->proc_id, bm->msgid, bm->sd, bm->msg)
#define fmtlogit(bm) logit("%s(%d, 0x%02x, %s, %s, %s, %s, %s, %s)", __func__, \
bm->pri, bm->flags, bm->hostname ? bm->hostname : "-", \
bm->app_name ? bm->app_name : "-", \
bm->proc_id ? bm->proc_id : "-", \
bm->msgid ? bm->msgid : "-", \
bm->sd ? bm->sd : "-", bm->msg ? bm->msg : "-")
static int fmt3164(struct buf_msg *buffer, char *fmt, struct iovec *iov, size_t iovmax)
{