about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-09-06 18:07:16 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-09-06 18:07:16 +0200
commitc409eeacc07f2b34086a8b1d0e3d02d580996c88 (patch)
tree044a49cd199c35b20af19925076a08214840e7a4
parent398f950ab21f1d34a674dba4f2bf80a003bc4237 (diff)
downloadredo-c-c409eeacc07f2b34086a8b1d0e3d02d580996c88.tar.gz
redo-c-c409eeacc07f2b34086a8b1d0e3d02d580996c88.tar.xz
redo-c-c409eeacc07f2b34086a8b1d0e3d02d580996c88.zip
Error handling in targetchdir
-rw-r--r--redo.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/redo.c b/redo.c
index 34d939c..b46676a 100644
--- a/redo.c
+++ b/redo.c
@@ -349,8 +349,15 @@ targetchdir(char *target) {
 		int fd;
 		*base = 0;
 		fd = openat(dir_fd, target, O_RDONLY | O_DIRECTORY);
+		if (fd < 0) {
+			perror("openat dir");
+			exit(111);
+		}
 		*base = '/';
-		fchdir(fd);
+		if (fchdir(fd) < 0) {
+			perror("chdir");
+			exit(111);
+		}
 		close(fd);
 		return base+1;
 	} else {