passt: Improper use of negative value (CWE-394)
Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
0786b2e60a
commit
bb76470090
1 changed files with 14 additions and 5 deletions
19
passt.c
19
passt.c
|
@ -421,13 +421,22 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
pcap_init(&c);
|
pcap_init(&c);
|
||||||
|
|
||||||
if (!c.foreground)
|
if (!c.foreground) {
|
||||||
/* NOLINTNEXTLINE(android-cloexec-open): see __daemon() */
|
/* NOLINTNEXTLINE(android-cloexec-open): see __daemon() */
|
||||||
devnull_fd = open("/dev/null", O_RDWR);
|
if ((devnull_fd = open("/dev/null", O_RDWR)) < 0) {
|
||||||
|
perror("/dev/null open");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (*c.pid_file)
|
if (*c.pid_file) {
|
||||||
pidfile_fd = open(c.pid_file, O_CREAT | O_WRONLY | O_CLOEXEC,
|
if ((pidfile_fd = open(c.pid_file,
|
||||||
S_IRUSR | S_IWUSR);
|
O_CREAT | O_WRONLY | O_CLOEXEC,
|
||||||
|
S_IRUSR | S_IWUSR)) < 0) {
|
||||||
|
perror("PID file open");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sandbox(&c)) {
|
if (sandbox(&c)) {
|
||||||
err("Failed to sandbox process, exiting\n");
|
err("Failed to sandbox process, exiting\n");
|
||||||
|
|
Loading…
Reference in a new issue