summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/fts.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
committerdes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
commit834fb25a9ed2240101506d137b5be7d71c75f306 (patch)
tree4002c72cd1ed11909f7640bea343988cfcf63c5b /lib/libc/gen/fts.c
parent98b742f57cafbed05c101e60cc131f5980f044d0 (diff)
parent787cf8d03f1c58ada088933408f30fd63de85bf2 (diff)
downloadFreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.zip
FreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.tar.gz
IFH@204581
Diffstat (limited to 'lib/libc/gen/fts.c')
-rw-r--r--lib/libc/gen/fts.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index 41443c5..1c547a1 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -124,6 +124,12 @@ fts_open(argv, options, compar)
return (NULL);
}
+ /* fts_open() requires at least one path */
+ if (*argv == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
/* Allocate/initialize the stream. */
if ((priv = malloc(sizeof(*priv))) == NULL)
return (NULL);
@@ -836,11 +842,8 @@ mem1: saved_errno = errno;
* If not changing directories, reset the path back to original
* state.
*/
- if (ISSET(FTS_NOCHDIR)) {
- if (len == sp->fts_pathlen || nitems == 0)
- --cp;
- *cp = '\0';
- }
+ if (ISSET(FTS_NOCHDIR))
+ sp->fts_path[cur->fts_pathlen] = '\0';
/*
* If descended after called from fts_children or after called from
OpenPOWER on IntegriCloud