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>
This commit is contained in:
Toni Uhlig
2022-11-09 11:21:55 +01:00
parent bc346a28f4
commit ea1698504c
4 changed files with 3 additions and 6 deletions

View File

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

View File

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

View File

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

View File

@@ -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':