From d6ec71284d9dc4f9bf7b773e8f7fca9d9fb4d3f4 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 27 Sep 2020 17:21:07 +0200 Subject: logging: Introduce MAX_LOG_SIZE for the magic number 4096 Change-Id: Ia9645098dffecd29242857de8f1aea6b9aca5918 --- src/logging.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/logging.c b/src/logging.c index 212b0b99..e018916a 100644 --- a/src/logging.c +++ b/src/logging.c @@ -56,6 +56,9 @@ #include /* for LOGGING_STR. */ +/* maximum length of the log string of a single log event (typically line), including NUL termination */ +#define MAX_LOG_SIZE 4096 + osmo_static_assert(_LOG_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), enum_logging_ctx_items_fit_in_struct_log_context); osmo_static_assert(_LOG_FLT_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), @@ -390,7 +393,7 @@ static void _output(struct log_target *target, unsigned int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap) { - char buf[4096]; + char buf[MAX_LOG_SIZE]; int ret, len = 0, offset = 0, rem = sizeof(buf); const char *c_subsys = NULL; -- cgit v1.2.3