Fix SIGSEGV/stacksmash in UDP logger.

The bug was reported in #197. Caused by insufficient size of logging
buffer.
This commit is contained in:
Vadim Vetrov 2024-12-01 18:19:09 +03:00
parent fd1ae1e574
commit aefabe7e0a
No known key found for this signature in database
GPG Key ID: E8A308689D7A73A5

View File

@ -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);
}