]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some minor issues
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 30 Oct 2023 15:48:52 +0000 (15:48 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 30 Oct 2023 15:48:52 +0000 (15:48 +0000)
src/libserver/logger/logger.c

index 58cb31969da1f22c15fdf10cb5c58ff12f4eccee..7a6f62dddf43f3f9a526edc941e0322d262843d9 100644 (file)
@@ -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) {