summaryrefslogtreecommitdiff
path: root/lib/fts.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2010-09-13 07:29:18 +0200
committerJim Meyering <meyering@redhat.com>2010-09-13 07:29:18 +0200
commit40af2cd5c8a49d2eaaaf6c0cd54ce0198282f9fa (patch)
treef84973b582ee1c1a1a409efa5a77d82a3e0f46bb /lib/fts.c
parentcd3df4488a72cb4dd3b490a8d8087d0130e64ff1 (diff)
downloadgnulib-40af2cd5c8a49d2eaaaf6c0cd54ce0198282f9fa.tar.gz
fts: don't operate on an invalid file descriptor after failed dup
* lib/fts.c (fts_build): Don't call set_cloexec_flag on a negative file descriptor.
Diffstat (limited to 'lib/fts.c')
-rw-r--r--lib/fts.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/fts.c b/lib/fts.c
index a308a8c94e..4b89ee780b 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1305,7 +1305,8 @@ fts_build (register FTS *sp, int type)
if (ISSET(FTS_CWDFD) && 0 <= dir_fd)
{
dir_fd = dup (dir_fd);
- set_cloexec_flag (dir_fd, true);
+ if (0 <= dir_fd)
+ set_cloexec_flag (dir_fd, true);
}
if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) {
if (nlinks && type == BREAD)