summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-03-11 09:46:09 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-03-11 09:46:09 +0100
commit1b838e1c5b61c37abc712609e64925fcad0bc2a2 (patch)
tree58e1bb0c2098f097d227baec1f3a00cd120951b5
parent5414c0e869efb4cdd3df8983a707711790bf7432 (diff)
downloadtcpdump-1b838e1c5b61c37abc712609e64925fcad0bc2a2.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();