From: Francois-Xavier Le Bail Date: Sat, 11 Mar 2023 08:46:09 +0000 (+0100) Subject: instrument functions: Add a length check X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/1b838e1c5b61c37abc712609e64925fcad0bc2a2 instrument functions: Add a length check We need space for the '\0'. Same as in tcpslice to fix a Coverity issue. Moreover: Use '\0' for the null character. --- diff --git a/instrument-functions.c b/instrument-functions.c index fb2314dd..aff33ccd 100644 --- a/instrument-functions.c +++ b/instrument-functions.c @@ -114,7 +114,12 @@ static void print_debug(void *this_fn, void *call_site, action_type action) perror("failed to find executable\n"); return; } - pgm_name[ret] = 0; + if (ret == sizeof(pgm_name)) { + /* no space for the '\0' */ + printf("truncation may have occurred\n"); + return; + } + pgm_name[ret] = '\0'; bfd_init();