From aefabe7e0aee9903e05a1199b822710335dcd16a Mon Sep 17 00:00:00 2001 From: Vadim Vetrov Date: Sun, 1 Dec 2024 18:19:09 +0300 Subject: [PATCH] Fix SIGSEGV/stacksmash in UDP logger. The bug was reported in #197. Caused by insufficient size of logging buffer. --- mangle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mangle.c b/mangle.c index 5aaa290..cc8d811 100644 --- a/mangle.c +++ b/mangle.c @@ -338,15 +338,15 @@ int process_udp_packet(const struct section_config_t *section, const uint8_t *pk goto accept; } - if (dlen > 10 && config.verbose >= VERBOSE_TRACE) { - char buf[50]; - char *bufpt = buf; + if (dlen > 10 && config.verbose == VERBOSE_TRACE) { + char logging_buf[128]; + char *bufpt = logging_buf; bufpt += sprintf(bufpt, "UDP payload start: [ "); for (int i = 0; i < 10; i++) { bufpt += sprintf(bufpt, "%02x ", data[i]); } bufpt += sprintf(bufpt, "]"); - lgtrace_addp("%s", buf); + lgtrace_addp("%s", logging_buf); }