diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-28 14:11:46 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-28 14:11:46 +0200 |
commit | ea929e0a287f9031be9144918350d6acf7292bf9 (patch) | |
tree | 9de658c6dda67bde5e32ec643fa31ac35e2ed139 | |
parent | 2012f8697caabceb3e45260367fe3524dba7015f (diff) | |
download | nq-ea929e0a287f9031be9144918350d6acf7292bf9.tar.gz nq-ea929e0a287f9031be9144918350d6acf7292bf9.tar.xz nq-ea929e0a287f9031be9144918350d6acf7292bf9.zip |
fq: open dirfd with O_DIRECTORY to fail early
-rw-r--r-- | fq.c | 6 |
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; |