From 50f6ad74cbe8ec544fb7f202e9242b04a015f4b8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 31 Jul 2022 18:43:46 +0200 Subject: [PATCH] syslogd: ensure tag is <= 32 chars for RFC3164 output This may cause a bit of a regression for some users, but the RFC is crystal clear on this point, the tag MUST NOT exceed 32 characters. Signed-off-by: Joachim Wiberg --- src/syslogd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/syslogd.c b/src/syslogd.c index 9064b48..c9aaa2b 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -1930,7 +1930,15 @@ static int fmt3164(struct buf_msg *buffer, char *fmt, struct iovec *iov, size_t } if (buffer->app_name) { - pushiov(iov, i, buffer->app_name); + char tag[33]; + + /* + * RFC3164, sec 4.1.3: "The TAG is a string of ABNF + * alphanumeric characters that MUST NOT exceed 32 + * characters." + */ + strlcpy(tag, buffer->app_name, sizeof(tag)); + pushiov(iov, i, tag); if (buffer->proc_id) { pushiov(iov, i, "["); pushiov(iov, i, buffer->proc_id);