summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-09-08 07:01:32 +0200
committerRalf Baechle <ralf@linux-mips.org>2017-09-08 07:05:12 +0200
commitd29c9ac181e03339642a838aad4bb51c176ae66d (patch)
treea0c9d09a8ea152dfa58afb72ba8617baa8491512
parent24b128490dbfcb6d93247114993639a0298c596b (diff)
daemon: check return value of chdir() in daemon_start_fork_pid()
libtool: compile: gcc -DHAVE_CONFIG_H -I. -DAX25_SYSCONFDIR=\"/usr/local/etc/ax25/\" -DAX25_LOCALSTATEDIR=\"/usr/local/var/ax25/\" -O2 -Wall -D_FORTIFY_SOURCE=2 -flto -MT daemon.lo -MD -MP -MF .deps/daemon.Tpo -c daemon.c -fPIC -DPIC -o .libs/daemon.o daemon.c: In function ‘daemon_start_fork_pid’: daemon.c:167:2: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result] chdir("/"); ^~~~~~~~~~ Found by FORTIFY_SOURCE. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--daemon.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/daemon.c b/daemon.c
index 88d1ed9..dcc5669 100644
--- a/daemon.c
+++ b/daemon.c
@@ -46,7 +46,8 @@ int daemon_start(int ignsigcld)
out:
/* Move the current directory to root, to make sure we aren't on a */
/* mounted filesystem. */
- chdir("/");
+ if (chdir("/") < 0)
+ return 0;
/* Clear any inherited file mode creation mask. */
umask(0);