summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-24 08:27:59 +0000
committerJim Meyering <jim@meyering.net>2003-02-24 08:27:59 +0000
commit0818c3e24c430e3263c4b8fa6b3bffac9417be17 (patch)
treeb8d0027d5cc08eea4ab3fa0e3bd43c46b7844f4e /lib
parentf30cda6bd2ac0d103fdbd184f6cdb25e64aafb50 (diff)
downloadcoreutils-0818c3e24c430e3263c4b8fa6b3bffac9417be17.tar.xz
(fts_open): If fts_alloc returns NULL, don't dereference it.
(fts_read): If fts_safe_changedir fails because it is not able to chdir into a subdirectory, then inform the caller.
Diffstat (limited to 'lib')
-rw-r--r--lib/fts.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/fts.c b/lib/fts.c
index 35374a094..1b8923c9f 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -136,7 +136,8 @@ fts_open(argv, options, compar)
goto mem3;
}
- p = fts_alloc(sp, *argv, len);
+ if ((p = fts_alloc(sp, *argv, len)) == NULL)
+ goto mem3;
p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent;
p->fts_accpath = p->fts_name;
@@ -369,6 +370,11 @@ fts_read(sp)
} else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) {
if (ISSET(FTS_STOP))
return (NULL);
+ /* If fts_build's call to fts_safe_changedir failed
+ because it was not able to fchdir into a
+ subdirectory, tell the caller. */
+ if (p->fts_errno)
+ p->fts_info = FTS_ERR;
return (p);
}
p = sp->fts_child;