aboutgitcodebugslistschat
path: root/pasta.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-21 09:41:13 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-21 09:41:13 +0200
commit627e18fa8ad000ed92405cff3a88c36fd5f3027e (patch)
tree5caf72002139dd6bc80cd424de1730f8602cbb9d /pasta.c
parentc3f8e4d2cd55e57419478ff849265d1e342e7990 (diff)
downloadpasst-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.gz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.bz2
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.lz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.xz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.zst
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.zip
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 <sbrivio@redhat.com>
Diffstat (limited to 'pasta.c')
-rw-r--r--pasta.c11
1 files changed, 7 insertions, 4 deletions
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)