From d29c9ac181e03339642a838aad4bb51c176ae66d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 8 Sep 2017 07:01:32 +0200 Subject: daemon: check return value of chdir() in daemon_start_fork_pid() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- daemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'daemon.c') 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); -- cgit v1.2.3