summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-03-11 09:20:08 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-03-11 09:41:59 +0100
commite1a66ebdde63aa5c85fd0da213407d49bc8fdafd (patch)
treeed3027f6d379cbfd5dcc197474aa9c82d27f8a6d
parentcd1aa996b0a82cbff0801f1154fe317398a9e467 (diff)
downloadlibpcap-e1a66ebdde63aa5c85fd0da213407d49bc8fdafd.tar.gz
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.
-rw-r--r--instrument-functions.c7
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();