summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-10-05 21:11:04 +0000
committerdelphij <delphij@FreeBSD.org>2009-10-05 21:11:04 +0000
commita71c2bfcab51b8a7e7359a2c1a1a7ba7612bc6d7 (patch)
treea39168e153406d9181496363bd644a27c25e9db0 /lib
parent7e261d5659ff5086d3f0055f0d6ba9ede8e15f30 (diff)
downloadFreeBSD-src-a71c2bfcab51b8a7e7359a2c1a1a7ba7612bc6d7.zip
FreeBSD-src-a71c2bfcab51b8a7e7359a2c1a1a7ba7612bc6d7.tar.gz
fts_open() requires that the list passed as argument to contain at least
one path. When the list is empty (contain only a NULL pointer), return EINVAL instead of pretending to succeed, which will cause a NULL pointer deference in a later fts_read() call. Noticed by: Christoph Mallon (via rdivacky@) MFC after: 2 weeks
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/fts.34
-rw-r--r--lib/libc/gen/fts.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3
index 8e1a1e4..dfe2de0 100644
--- a/lib/libc/gen/fts.3
+++ b/lib/libc/gen/fts.3
@@ -28,7 +28,7 @@
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
.\" $FreeBSD$
.\"
-.Dd January 26, 2008
+.Dd October 5, 2009
.Dt FTS 3
.Os
.Sh NAME
@@ -776,7 +776,7 @@ may fail and set
as follows:
.Bl -tag -width Er
.It Bq Er EINVAL
-The options were invalid.
+The options were invalid, or the list were empty.
.El
.Sh SEE ALSO
.Xr find 1 ,
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index 41443c5..392bda9 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);
OpenPOWER on IntegriCloud