summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2023-08-26 12:49:39 +0200
committerToni Uhlig <matzeton@googlemail.com>2023-08-27 12:49:39 +0200
commitb01498f011eac9b91c076901ffb5c9c04e7691c0 (patch)
tree05e0595a194da3b6f32109777b210d1b4959ba46 /examples
parentcc60e819e802b8f5b36377d95ecb33db71d1d14b (diff)
Fix some GCC-12 warnings.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/c-analysed/c-analysed.c5
-rw-r--r--examples/c-captured/c-captured.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/examples/c-analysed/c-analysed.c b/examples/c-analysed/c-analysed.c
index e9c71b978..3f48a01d8 100644
--- a/examples/c-analysed/c-analysed.c
+++ b/examples/c-analysed/c-analysed.c
@@ -8,7 +8,8 @@
#include "utils.h"
#define MIN(a, b) (a > b ? b : a)
-#define BUFFER_REMAINING(siz) (NETWORK_BUFFER_MAX_SIZE / 3 - siz)
+#define BUFFER_MAX (NETWORK_BUFFER_MAX_SIZE / 3)
+#define BUFFER_REMAINING(siz) (BUFFER_MAX - siz)
typedef char csv_buf_t[(NETWORK_BUFFER_MAX_SIZE / 3) + 1];
static int main_thread_shutdown = 0;
@@ -155,7 +156,7 @@ static void csv_buf_add(csv_buf_t buf, size_t * const csv_buf_used, char const *
{
return;
}
- strncat(buf, str, len);
+ snprintf(buf + *csv_buf_used, BUFFER_MAX - len, "%.*s", (int)len, str);
}
else
{
diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c
index c914c6991..12829267c 100644
--- a/examples/c-captured/c-captured.c
+++ b/examples/c-captured/c-captured.c
@@ -665,7 +665,7 @@ static void syslog_event(struct nDPIsrvd_socket * const sock,
}
if (src_port != NULL && dst_port != NULL)
{
- size_t src_port_len, dst_port_len;
+ size_t src_port_len = 0, dst_port_len = 0;
char const * const tmp_src_port_str = TOKEN_GET_VALUE(sock, src_port, &src_port_len);
char const * const tmp_dst_port_str = TOKEN_GET_VALUE(sock, dst_port, &dst_port_len);
if (tmp_src_port_str != NULL && tmp_dst_port_str != NULL)