From ceddcac74a6eafae8d959adcbfee17d4cae2c3a8 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 5 Apr 2022 12:33:31 +0200 Subject: 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 --- conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 2412fc6..5c614cd 100644 --- a/conf.c +++ b/conf.c @@ -1035,7 +1035,7 @@ void conf(struct ctx *c, int argc, char **argv) usage(argv[0]); } - ret = snprintf(c->sock_path, sizeof(c->sock_path), "%s", + ret = snprintf(c->sock_path, UNIX_SOCK_MAX - 1, "%s", optarg); if (ret <= 0 || ret >= (int)sizeof(c->pcap)) { err("Invalid socket path: %s", optarg); @@ -1048,9 +1048,9 @@ void conf(struct ctx *c, int argc, char **argv) usage(argv[0]); } - ret = snprintf(c->pasta_ifn, sizeof(c->pasta_ifn), "%s", + ret = snprintf(c->pasta_ifn, IFNAMSIZ - 1, "%s", optarg); - if (ret <= 0 || ret >= (int)sizeof(c->pasta_ifn)) { + if (ret <= 0 || ret >= IFNAMSIZ - 1) { err("Invalid interface name: %s", optarg); usage(argv[0]); } -- cgit v1.2.3