summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-28 14:11:46 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-28 14:11:46 +0200
commitea929e0a287f9031be9144918350d6acf7292bf9 (patch)
tree9de658c6dda67bde5e32ec643fa31ac35e2ed139
parent2012f8697caabceb3e45260367fe3524dba7015f (diff)
downloadnq-ea929e0a287f9031be9144918350d6acf7292bf9.tar.gz
nq-ea929e0a287f9031be9144918350d6acf7292bf9.tar.xz
nq-ea929e0a287f9031be9144918350d6acf7292bf9.zip
fq: open dirfd with O_DIRECTORY to fail early
-rw-r--r--fq.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fq.c b/fq.c
index dc165db..313f773 100644
--- a/fq.c
+++ b/fq.c
@@ -83,9 +83,11 @@ main(int argc, char *argv[])
 	if (!path)
 		path = ".";
 
-	dirfd = open(path, O_RDONLY);
-	if (dirfd < 0)
+	dirfd = open(path, O_RDONLY | O_DIRECTORY);
+	if (dirfd < 0) {
+		perror("open dir");
 		exit(111);
+	}
 
 	if (optind == argc) {	/* behave as if $NQDIR/,* was passed. */
 		DIR *dir;