aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 12:33:31 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commitceddcac74a6eafae8d959adcbfee17d4cae2c3a8 (patch)
treebd7c719bfc30063c3b8ee1f69e227e4176793ff4 /tap.c
parente46f67f15230e07ef35f4f54126a47ef5a60238b (diff)
downloadpasst-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar.gz
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar.bz2
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar.lz
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar.xz
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.tar.zst
passt-ceddcac74a6eafae8d959adcbfee17d4cae2c3a8.zip
conf, tap: False "Buffer not null terminated" positives, CWE-170
Those strings are actually guaranteed to be NULL-terminated. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tap.c b/tap.c
index 8110577..04ceade 100644
--- a/tap.c
+++ b/tap.c
@@ -798,9 +798,9 @@ static void tap_sock_unix_init(struct ctx *c)
char *path = addr.sun_path;
if (*c->sock_path)
- strncpy(path, c->sock_path, UNIX_PATH_MAX);
+ memcpy(path, c->sock_path, UNIX_PATH_MAX);
else
- snprintf(path, UNIX_PATH_MAX, UNIX_SOCK_PATH, i);
+ snprintf(path, UNIX_PATH_MAX - 1, UNIX_SOCK_PATH, i);
ex = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (ex < 0) {
@@ -899,7 +899,7 @@ static int tap_ns_tun(void *arg)
int flags = O_RDWR | O_NONBLOCK | O_CLOEXEC;
struct ctx *c = (struct ctx *)arg;
- strncpy(ifr.ifr_name, c->pasta_ifn, IFNAMSIZ);
+ memcpy(ifr.ifr_name, c->pasta_ifn, IFNAMSIZ);
if (ns_enter(c) ||
(tun_ns_fd = open("/dev/net/tun", flags)) < 0 ||