aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2023-07-22 12:45:45 +0200
committerGitHub <noreply@github.com>2023-07-22 12:45:45 +0200
commit88a757c4cd3a6912fa5c8405677168e6a4f06ab1 (patch)
tree3caa60be45d66be1234f03268f6d943a8b5effe6
parent6831187d6288d6482d99ec2c72c7d0794e4020cf (diff)
Fix string truncation. (#2056)
ndpi_main.c: In function ‘ndpi_load_ip_category’: ndpi_main.c:6598:3: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation] 6598 | strncpy(ipbuf, ip_address_and_mask, sizeof(ipbuf)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--src/lib/ndpi_main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index d857c58b5..a34571c1d 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -6595,7 +6595,7 @@ int ndpi_load_ip_category(struct ndpi_detection_module_struct *ndpi_str,
if(!ndpi_str->custom_categories.ipAddresses_shadow)
return(-1);
- strncpy(ipbuf, ip_address_and_mask, sizeof(ipbuf));
+ strncpy(ipbuf, ip_address_and_mask, sizeof(ipbuf) - 1);
ipbuf[sizeof(ipbuf) - 1] = '\0';
ptr = strrchr(ipbuf, '/');