Skip to content

Commit

Permalink
Fix string truncation. (#2056)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
utoni authored Jul 22, 2023
1 parent 6831187 commit 88a757c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
Expand Down

0 comments on commit 88a757c

Please sign in to comment.