aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2022-11-09 11:21:55 +0100
committerToni Uhlig <matzeton@googlemail.com>2022-11-13 11:21:55 +0100
commitea1698504cc73df41af0b9df20d5133330ee6977 (patch)
tree28ea33df1e11eb9ad5a5921b502ed1b1df063bf6
parentbc346a28f46d4f341293182f33919f6dbe7b2391 (diff)
nDPIsrvd: Provide workaround for change user/group.
* nDPId/nDPIsrvd/c-examples: Parameter parsing needs to be improved if `strdup()` in combination with static strings is used. * Other non-critical fixes. Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--dependencies/nDPIsrvd.h2
-rw-r--r--examples/c-captured/c-captured.c2
-rw-r--r--nDPId.c4
-rw-r--r--nDPIsrvd.c1
4 files changed, 3 insertions, 6 deletions
diff --git a/dependencies/nDPIsrvd.h b/dependencies/nDPIsrvd.h
index 1c0b4c23e..806bd09c8 100644
--- a/dependencies/nDPIsrvd.h
+++ b/dependencies/nDPIsrvd.h
@@ -1647,7 +1647,7 @@ static inline void nDPIsrvd_flow_info(struct nDPIsrvd_socket const * const sock,
static inline int nDPIsrvd_json_buffer_length(struct nDPIsrvd_socket const * const sock)
{
- return (int)sock->buffer.json_string_length;
+ return (int)sock->buffer.json_string_length - NETWORK_BUFFER_LENGTH_DIGITS;
}
static inline char const *nDPIsrvd_json_buffer_string(struct nDPIsrvd_socket const * const sock)
diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c
index e9fccba76..78c612723 100644
--- a/examples/c-captured/c-captured.c
+++ b/examples/c-captured/c-captured.c
@@ -372,7 +372,7 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
if (pkt == NULL)
{
syslog(LOG_DAEMON | LOG_ERR, "%s", "No packet data available.");
- syslog(LOG_DAEMON | LOG_ERR, "JSON String: \"%.*s\"", nDPIsrvd_json_buffer_length(sock), nDPIsrvd_json_buffer_string(sock));
+ syslog(LOG_DAEMON | LOG_ERR, "JSON String: '%.*s'", nDPIsrvd_json_buffer_length(sock), nDPIsrvd_json_buffer_string(sock));
return CALLBACK_OK;
}
if (flow_user->packets == NULL)
diff --git a/nDPId.c b/nDPId.c
index 0fc4f55bf..65925cdd0 100644
--- a/nDPId.c
+++ b/nDPId.c
@@ -2353,8 +2353,6 @@ static void base64encode(uint8_t const * const data_buf,
int padCount = dataLength % 3;
uint8_t n0, n1, n2, n3;
- *resultSize = 0;
-
/* increment over the length of the string, three characters at a time */
for (x = 0; x < dataLength; x += 3)
{
@@ -2584,7 +2582,7 @@ static void jsonize_packet_event(struct nDPId_reader_thread * const reader_threa
ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_type", pkt_type);
ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_l3_offset", pkt_l3_offset);
ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_l4_offset", pkt_l4_offset);
- ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_len", header->caplen);
+ ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_len", header->len);
ndpi_serialize_string_uint32(&workflow->ndpi_serializer, "pkt_l4_len", pkt_l4_len);
ndpi_serialize_string_uint64(&workflow->ndpi_serializer, "thread_ts_usec", workflow->last_thread_time);
diff --git a/nDPIsrvd.c b/nDPIsrvd.c
index 81e0d7c44..eab484e7e 100644
--- a/nDPIsrvd.c
+++ b/nDPIsrvd.c
@@ -826,7 +826,6 @@ static int nDPIsrvd_parse_options(int argc, char ** argv)
}
break;
case 'u':
- free(nDPIsrvd_options.user);
nDPIsrvd_options.user = strdup(optarg);
break;
case 'g':