From 627e18fa8ad000ed92405cff3a88c36fd5f3027e Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 21 Oct 2021 09:41:13 +0200 Subject: passt: Add cppcheck target, test, and address resulting warnings ...mostly false positives, but a number of very relevant ones too, in tcp_get_sndbuf(), tcp_conn_from_tap(), and siphash PREAMBLE(). Signed-off-by: Stefano Brivio --- pasta.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pasta.c') diff --git a/pasta.c b/pasta.c index c13743b..5150a3e 100644 --- a/pasta.c +++ b/pasta.c @@ -167,9 +167,8 @@ netns: */ void pasta_start_ns(struct ctx *c) { - char buf[BUFSIZ], *shell, proc_path[PATH_MAX]; - int euid = geteuid(); - int fd; + int euid = geteuid(), fd; + char *shell; c->foreground = 1; if (!c->debug) @@ -181,6 +180,8 @@ void pasta_start_ns(struct ctx *c) } if (pasta_child_pid) { + char proc_path[PATH_MAX]; + NS_CALL(pasta_wait_for_ns, c); snprintf(proc_path, PATH_MAX, "/proc/%i/ns/net", @@ -197,7 +198,9 @@ void pasta_start_ns(struct ctx *c) } if (!c->netns_only) { - snprintf(buf, BUFSIZ, "%u %u %u", 0, euid, 1); + char buf[BUFSIZ]; + + snprintf(buf, BUFSIZ, "%i %i %i", 0, euid, 1); fd = open("/proc/self/uid_map", O_WRONLY); if (write(fd, buf, strlen(buf)) < 0) -- cgit v1.2.3