From 2c95b31210ebcc12556d1a30b6df2938fbec879c Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 20 Nov 2022 10:22:02 +0100 Subject: nDPId-test: Reworked I/O handling to prevent some endless loop scenarios. Fixed a race condition in the memory wrapper as well. * nDPId: Instead of sending too long JSON strings, log an error and some parts. Signed-off-by: Toni Uhlig --- nDPId.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nDPId.c') diff --git a/nDPId.c b/nDPId.c index ca131bbfd..2c247b648 100644 --- a/nDPId.c +++ b/nDPId.c @@ -2221,7 +2221,7 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread, (int)json_str_len, json_str); - if (s_ret < 0 || s_ret == (int)sizeof(newline_json_str)) + if (s_ret < 0 || s_ret >= (int)sizeof(newline_json_str)) { logger(1, "[%8llu, %zu] JSON buffer prepare failed: snprintf returned %d, buffer size %zu", @@ -2229,6 +2229,15 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread, reader_thread->array_index, s_ret, sizeof(newline_json_str)); + if (s_ret >= (int)sizeof(newline_json_str)) + { + logger(1, + "[%8llu, %zu] JSON string: %.*s...", + workflow->packets_captured, + reader_thread->array_index, + ndpi_min(512, NETWORK_BUFFER_MAX_SIZE), + newline_json_str); + } return; } -- cgit v1.2.3