diff options
author | Klement Sekera <ksekera@cisco.com> | 2021-11-16 12:19:26 +0100 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2022-01-28 14:36:39 +0000 |
commit | aa9903cabfd44ed9c88d1f624a39096ff7fee37f (patch) | |
tree | edd2e875d8ae034955d8f29251610cdf00dd3080 | |
parent | 616447c392311791e630a604a07a2c7e47dbb7d6 (diff) |
misc: vppctl - fix coverity warning
Check that provided path fits into defined buffer. Don't write too many
bytes to avoid having an unterminated string.
Type: fix
Fixes: 31f192434660
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I1ea8b6d6a3474c032e542b6980ed14bac72093a8
-rw-r--r-- | src/vpp/app/vppctl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vpp/app/vppctl.c b/src/vpp/app/vppctl.c index c9f33abf7ab..de5572d6bfa 100644 --- a/src/vpp/app/vppctl.c +++ b/src/vpp/app/vppctl.c @@ -192,6 +192,13 @@ main (int argc, char *argv[]) struct sockaddr_un saddr = { 0 }; saddr.sun_family = AF_UNIX; + + if (strlen (sock_fname) > sizeof (saddr.sun_path) - 1) + { + perror ("socket path too long"); + exit (1); + } + strncpy (saddr.sun_path, sock_fname, sizeof (saddr.sun_path) - 1); sock_fd = socket (AF_UNIX, SOCK_STREAM, 0); |