diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-04-05 07:24:48 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-04-07 11:44:35 +0200 |
commit | 0786b2e60a71c94b4243224d01a810a4a52b8b72 (patch) | |
tree | 944e0f35641d5d37b755c72b11436838dbed6f13 /conf.c | |
parent | 48bc843d6e406a142b5b07e57a3d7d242c2bed03 (diff) | |
download | passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar.gz passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar.bz2 passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar.lz passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar.xz passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.tar.zst passt-0786b2e60a71c94b4243224d01a810a4a52b8b72.zip |
conf, packet: Operands don't affect result, CWE-569
Reported by Coverity.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -369,6 +369,7 @@ static int conf_ns_opt(struct ctx *c, int ufd = -1, nfd = -1, try, ret, netns_only_reset = c->netns_only; char userns[PATH_MAX] = { 0 }, netns[PATH_MAX]; char *endptr; + long pid_arg; pid_t pid; if (c->netns_only && *conf_userns) { @@ -379,10 +380,12 @@ static int conf_ns_opt(struct ctx *c, /* It might be a PID, a netns path, or a netns name */ for (try = 0; try < 3; try++) { if (try == 0) { - pid = strtol(optarg, &endptr, 10); - if (*endptr || pid > INT_MAX) + pid_arg = strtol(optarg, &endptr, 10); + if (*endptr || pid_arg < 0 || pid_arg > INT_MAX) continue; + pid = pid_arg; + if (!*conf_userns && !c->netns_only) { ret = snprintf(userns, PATH_MAX, "/proc/%i/ns/user", pid); |