From e1a66ebdde63aa5c85fd0da213407d49bc8fdafd Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Sat, 11 Mar 2023 09:20:08 +0100 Subject: 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. --- instrument-functions.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'instrument-functions.c') 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(); -- cgit v1.2.3