diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2023-03-11 09:20:08 +0100 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2023-03-11 09:41:59 +0100 |
commit | e1a66ebdde63aa5c85fd0da213407d49bc8fdafd (patch) | |
tree | ed3027f6d379cbfd5dcc197474aa9c82d27f8a6d /instrument-functions.c | |
parent | cd1aa996b0a82cbff0801f1154fe317398a9e467 (diff) |
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.
Diffstat (limited to 'instrument-functions.c')
-rw-r--r-- | instrument-functions.c | 7 |
1 files changed, 6 insertions, 1 deletions
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(); |