]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: make each string generated in log_format_iovec() NUL terminated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Nov 2025 11:14:00 +0000 (20:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 Nov 2025 13:38:38 +0000 (22:38 +0900)
Nowadays, we append an extra NUL for each data if possible for safety.
We already do the same for example at write_to_kmsg(), log_do_context(),
write_to_journal(), log_struct_iovec_internal(), and so on.
This does not change any behavior, as the iov_len field is unchanged.

src/basic/log.c

index bd338d8294d86c3fb01a09f059f54f381a22709e..b0b4ba5c5050c3adbee54a240d25ac3a131cbfdc 100644 (file)
@@ -950,8 +950,6 @@ int log_format_iovec(
                 const char *format,
                 va_list ap) {
 
-        static const char nl = '\n';
-
         while (format && *n + 1 < iovec_len) {
                 va_list aq;
                 char *m;
@@ -975,7 +973,7 @@ int log_format_iovec(
 
                 iovec[(*n)++] = IOVEC_MAKE_STRING(m);
                 if (newline_separator)
-                        iovec[(*n)++] = IOVEC_MAKE((char *)&nl, 1);
+                        iovec[(*n)++] = IOVEC_MAKE_STRING("\n");
 
                 format = va_arg(ap, char *);
         }