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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-07-31 18:43:46 +02:00
parent 3969dbb8a6
commit 50f6ad74cb

View File

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