aboutgitcodebugslistschat
path: root/pasta.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 11:51:47 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commiteb3d3f367ea09b89d54f177ded1e874611d1020f (patch)
tree31fea867bba5f73506352c8a1188fa1309669cd2 /pasta.c
parentbb76470090dc21540e70c3417fe0227c5a62cce2 (diff)
downloadpasst-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.gz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.bz2
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.lz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.xz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.zst
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.zip
treewide: Argument cannot be negative, CWE-687
Actually harmless. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'pasta.c')
-rw-r--r--pasta.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/pasta.c b/pasta.c
index 18df5d2..cd37d16 100644
--- a/pasta.c
+++ b/pasta.c
@@ -120,33 +120,24 @@ static int pasta_setup_ns(void *arg)
{
struct pasta_setup_ns_arg *a = (struct pasta_setup_ns_arg *)arg;
char *shell;
- int fd;
if (!a->c->netns_only) {
char buf[BUFSIZ];
snprintf(buf, BUFSIZ, "%i %i %i", 0, a->euid, 1);
- fd = open("/proc/self/uid_map", O_WRONLY | O_CLOEXEC);
- if (write(fd, buf, strlen(buf)) < 0)
- warn("Cannot set uid_map in namespace");
- close(fd);
+ FWRITE("/proc/self/uid_map", buf,
+ "Cannot set uid_map in namespace");
- fd = open("/proc/self/setgroups", O_WRONLY | O_CLOEXEC);
- if (write(fd, "deny", sizeof("deny")) < 0)
- warn("Cannot write to setgroups in namespace");
- close(fd);
+ FWRITE("/proc/self/setgroups", "deny",
+ "Cannot write to setgroups in namespace");
- fd = open("/proc/self/gid_map", O_WRONLY | O_CLOEXEC);
- if (write(fd, buf, strlen(buf)) < 0)
- warn("Cannot set gid_map in namespace");
- close(fd);
+ FWRITE("/proc/self/gid_map", buf,
+ "Cannot set gid_map in namespace");
}
- fd = open("/proc/sys/net/ipv4/ping_group_range", O_WRONLY | O_CLOEXEC);
- if (write(fd, "0 0", strlen("0 0")) < 0)
- warn("Cannot set ping_group_range, ICMP requests might fail");
- close(fd);
+ FWRITE("/proc/sys/net/ipv4/ping_group_range", "0 0",
+ "Cannot set ping_group_range, ICMP requests might fail");
shell = getenv("SHELL") ? getenv("SHELL") : "/bin/sh";
if (strstr(shell, "/bash"))