From c409eeacc07f2b34086a8b1d0e3d02d580996c88 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Sun, 6 Sep 2015 18:07:16 +0200 Subject: Error handling in targetchdir --- redo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 { -- cgit 1.4.1