mirror of
https://passt.top/passt
synced 2025-06-15 11:55:34 +02:00
passt: Address gcc 11 warnings
A mix of unchecked return values, a missing permission mask for open(2) with O_CREAT, and some false positives from -Wstringop-overflow and -Wmaybe-uninitialized. Reported-by: Martin Hauke <mardnh@gmx.de> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
087b5f4dbb
commit
1a563a0cbd
7 changed files with 91 additions and 33 deletions
13
passt.c
13
passt.c
|
@ -257,13 +257,16 @@ static void pid_file(struct ctx *c) {
|
|||
if (!*c->pid_file)
|
||||
return;
|
||||
|
||||
pid_fd = open(c->pid_file, O_CREAT | O_WRONLY);
|
||||
pid_fd = open(c->pid_file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
||||
if (pid_fd < 0)
|
||||
return;
|
||||
|
||||
n = snprintf(pid_buf, sizeof(pid_buf), "%i\n", getpid());
|
||||
|
||||
write(pid_fd, pid_buf, n);
|
||||
if (write(pid_fd, pid_buf, n) < 0) {
|
||||
perror("PID file write");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(pid_fd);
|
||||
}
|
||||
|
||||
|
@ -365,8 +368,10 @@ int main(int argc, char **argv)
|
|||
else
|
||||
__setlogmask(LOG_UPTO(LOG_INFO));
|
||||
|
||||
if (isatty(fileno(stdout)) && !c.foreground)
|
||||
daemon(0, 0);
|
||||
if (isatty(fileno(stdout)) && !c.foreground && daemon(0, 0)) {
|
||||
perror("daemon");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pid_file(&c);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue