aboutsummaryrefslogtreecommitdiff
path: root/nDPId.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2022-11-20 10:22:02 +0100
committerToni Uhlig <matzeton@googlemail.com>2022-12-02 22:11:57 +0100
commit2c95b31210ebcc12556d1a30b6df2938fbec879c (patch)
tree5f1021ff2c238942d4a920394eb9693b2716a839 /nDPId.c
parent532961af33c89436aac8585704701eafa2411980 (diff)
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 <matzeton@googlemail.com>
Diffstat (limited to 'nDPId.c')
-rw-r--r--nDPId.c11
1 files changed, 10 insertions, 1 deletions
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;
}