From: Daan De Meyer Date: Wed, 31 Jul 2024 09:39:04 +0000 (+0200) Subject: log: Fix size calculation for number of iovecs X-Git-Tag: v257-rc1~792^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc83ff3f55ee53fd9101d4e45736f3f996ee7ca6;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/basic/log.c b/src/basic/log.c index 09500f9cb05..571f5e43dce 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);