From 5a567472420dd6c3e47943cbca0ac527b0045eaa Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 30 Oct 2023 15:48:52 +0000 Subject: [PATCH] [Minor] Fix some minor issues --- src/libserver/logger/logger.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libserver/logger/logger.c b/src/libserver/logger/logger.c index 58cb31969..7a6f62ddd 100644 --- a/src/libserver/logger/logger.c +++ b/src/libserver/logger/logger.c @@ -1090,11 +1090,13 @@ gsize rspamd_log_fill_iov(struct iovec *iov, if (G_UNLIKELY(log_json)) { /* Perform JSON logging */ + guint slen = id ? strlen(id) : strlen("(NULL)"); + slen = MIN(RSPAMD_LOG_ID_LEN, slen); r = rspamd_snprintf(tmpbuf, sizeof(tmpbuf), "{\"ts\": %L, " "\"pid\": %P, " "\"severity\": \"%s\", " "\"worker_type\": \"%s\", " - "\"id\": \"%s\", " + "\"id\": \"%*.s\", " "\"module\": \"%s\", " "\"function\": \"%s\", " "\"message\": \"", @@ -1102,7 +1104,7 @@ gsize rspamd_log_fill_iov(struct iovec *iov, logger->pid, rspamd_get_log_severity_string(level_flags), logger->process_type, - id, + slen, id, module, function); iov[0].iov_base = tmpbuf; @@ -1111,6 +1113,8 @@ gsize rspamd_log_fill_iov(struct iovec *iov, iov[1].iov_len = mlen; iov[2].iov_base = (void *) "\"}\n"; iov[2].iov_len = sizeof("\"}\n") - 1; + + return 3; } else if (G_LIKELY(!log_rspamadm)) { if (!log_systemd) { -- 2.39.5