diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-07-31 11:39:04 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-07-31 13:12:55 +0200 |
commit | fc83ff3f55ee53fd9101d4e45736f3f996ee7ca6 (patch) | |
tree | d57d990a3f0426dbf11c10bb783a935818aa721f /src/basic/log.c | |
parent | execute: Drop log level to unit log level in exec_spawn() (diff) | |
download | systemd-fc83ff3f55ee53fd9101d4e45736f3f996ee7ca6.tar.xz systemd-fc83ff3f55ee53fd9101d4e45736f3f996ee7ca6.zip |
log: Fix size calculation for number of iovecs
Each log context field can expand to up to three iovecs (key, value
and newline) so let's fix the size calculation to take this into
account.
Diffstat (limited to '')
-rw-r--r-- | src/basic/log.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 09500f9cb0..571f5e43dc 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -747,7 +747,7 @@ static int write_to_journal( if (LOG_PRI(level) > log_target_max_level[LOG_TARGET_JOURNAL]) return 0; - iovec_len = MIN(6 + _log_context_num_fields * 2, IOVEC_MAX); + iovec_len = MIN(6 + _log_context_num_fields * 3, IOVEC_MAX); iovec = newa(struct iovec, iovec_len); log_do_header(header, sizeof(header), level, error, file, line, func, object_field, object, extra_field, extra); @@ -1099,7 +1099,7 @@ int log_struct_internal( int r; bool fallback = false; - iovec_len = MIN(17 + _log_context_num_fields * 2, IOVEC_MAX); + iovec_len = MIN(17 + _log_context_num_fields * 3, IOVEC_MAX); iovec = newa(struct iovec, iovec_len); /* If the journal is available do structured logging. @@ -1196,7 +1196,7 @@ int log_struct_iovec_internal( struct iovec *iovec; size_t n = 0, iovec_len; - iovec_len = MIN(1 + n_input_iovec * 2 + _log_context_num_fields * 2, IOVEC_MAX); + iovec_len = MIN(1 + n_input_iovec * 2 + _log_context_num_fields * 3, IOVEC_MAX); iovec = newa(struct iovec, iovec_len); log_do_header(header, sizeof(header), level, error, file, line, func, NULL, NULL, NULL, NULL); |