Commit 32d2fb48346b752db5098ea03c9c1800863bc71b

Stefan Sperling 2019-12-15T10:53:14

add missing error checks to an openat() call

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/lib/worktree.c b/lib/worktree.c
index 26a2616..b463e74 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2651,10 +2651,12 @@ status_new(void *arg, struct dirent *de, const char *parent_path, int dirfd)
 	}
 
 	if (de->d_type == DT_DIR) {
-		int subdirfd;
-		subdirfd = openat(dirfd, de->d_name,
+		int subdirfd = openat(dirfd, de->d_name,
 		    O_RDONLY | O_NOFOLLOW | O_DIRECTORY);
-		if (subdirfd != -1) {
+		if (subdirfd == -1) {
+			if (errno != ENOENT && errno != EACCES)
+				err = got_error_from_errno2("openat", path);
+		} else {
 			err = add_ignores(&a->ignores, a->worktree->root_path,
 			    path, subdirfd, ".cvsignore");
 			if (err == NULL)