File: 0005-guard-chdir.patch

package info (click to toggle)
tayga 0.9.2-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 7,135; sh: 1,234; makefile: 18
file content (37 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From: "Barak A. Pearlmutter" <barak+git@cs.nuim.ie>
Date: Wed, 18 Apr 2012 11:37:58 +0100
Subject: Guard chdir calls to avoid ignored-return-value warnings
---
 tayga.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tayga.c b/tayga.c
index fbd2e64..3886831 100644
--- a/tayga.c
+++ b/tayga.c
@@ -388,7 +388,11 @@ int main(int argc, char **argv)
 					"is specified in %s\n", conffile);
 			exit(1);
 		}
-		chdir("/");
+		if (chdir("/")) {
+			slog(LOG_CRIT, "Error: unable to chdir to /, aborting: %s\n",
+					strerror(errno));
+			exit(1);
+		}
 	} else if (chdir(gcfg->data_dir) < 0) {
 		if (user || errno != ENOENT) {
 			slog(LOG_CRIT, "Error: unable to chdir to %s, "
@@ -460,7 +464,11 @@ int main(int argc, char **argv)
 					gcfg->data_dir, strerror(errno));
 			exit(1);
 		}
-		chdir("/");
+		if (chdir("/")) {
+			slog(LOG_CRIT, "Error: unable to chdir to /, aborting: %s\n",
+					strerror(errno));
+			exit(1);
+		}
 	}
 
 	if (gr) {