aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-09-27 17:21:07 +0200
committerHarald Welte <laforge@osmocom.org>2020-09-29 20:02:16 +0200
commitd6ec71284d9dc4f9bf7b773e8f7fca9d9fb4d3f4 (patch)
tree381748bdca89d8c255b87b9028c535508f0581a2
parente4d9a2c5eb78f4188becb2dafb57b14e88e26fa1 (diff)
logging: Introduce MAX_LOG_SIZE for the magic number 4096
-rw-r--r--src/logging.c5
1 files changed, 4 insertions, 1 deletions
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 <osmocom/vty/logging.h> /* 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;