log: make each string generated in log_format_iovec() NUL terminated

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.
This commit is contained in:
Yu Watanabe
2025-11-16 20:14:00 +09:00
parent cfb6c54324
commit 1f546ab779

View 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 *);
}