summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/glob.3
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2001-07-29 00:52:37 +0000
committermikeh <mikeh@FreeBSD.org>2001-07-29 00:52:37 +0000
commitb925de092b1a33961fdd0e75d235854989006ed8 (patch)
treee6d5842b2c36ce1aaf0b631a9291c734c7cb9d3e /lib/libc/gen/glob.3
parentb9208b18d5d6f747062fbda0a70c27212711ab0a (diff)
downloadFreeBSD-src-b925de092b1a33961fdd0e75d235854989006ed8.zip
FreeBSD-src-b925de092b1a33961fdd0e75d235854989006ed8.tar.gz
Rename the GLOB_MAXPATH flag of glob(3) to GLOB_LIMIT to be compatible
with NetBSD and OpenBSD. glob(3) will now return GLOB_NOSPACE with errno set to 0 instead of GLOB_LIMIT when we match more than `gl_matchc' patterns. GLOB_MAXPATH has been left as an alias of GLOB_LIMIT to maintain backwards compatibility. Reviewed by: sheldonh, assar Obtained from: NetBSD/OpenBSD
Diffstat (limited to 'lib/libc/gen/glob.3')
-rw-r--r--lib/libc/gen/glob.333
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/libc/gen/glob.3 b/lib/libc/gen/glob.3
index 5c2da21..fcbb90f 100644
--- a/lib/libc/gen/glob.3
+++ b/lib/libc/gen/glob.3
@@ -260,14 +260,15 @@ character, avoiding any special interpretation of the character.
Expand patterns that start with
.Ql ~
to user name home directories.
-.It Dv GLOB_MAXPATH
+.It Dv GLOB_LIMIT
Limit the total number of returned pathnames to the value provided in
-.Fa gl_matchc .
-If
-.Fn glob
-would match more pathnames,
-.Dv GLOB_LIMIT
-will be returned.
+.Fa gl_matchc
+(default ARG_MAX).
+This option should be set for programs
+that can be coerced into a denial of service attack
+via patterns that expand to a very large number of matches,
+such as a long string of
+.Ql */../*/.. .
.El
.Pp
If, during the search, a directory is encountered that cannot be opened
@@ -377,21 +378,19 @@ file
.Aq Pa glob.h :
.Bl -tag -width GLOB_NOCHECK
.It Dv GLOB_NOSPACE
-An attempt to allocate memory failed.
+An attempt to allocate memory failed, or if
+.Fa errno
+was 0
+.Dv GLOB_LIMIT
+was specified in the flags and
+.Fa pglob\->gl_matchc
+or more patterns were patched.
.It Dv GLOB_ABEND
The scan was stopped because an error was encountered and either
.Dv GLOB_ERR
was set or
.Fa \*(lp*errfunc\*(rp\*(lp\*(rp
returned non-zero.
-.It Dv GLOB_LIMIT
-The flag
-.Dv GLOB_MAXPATH
-was provided, and the specified limit passed to
-.Fn glob
-in
-.Fa pglob\->gl_matchc
-was reached.
.El
.Pp
The arguments
@@ -427,8 +426,8 @@ compatible with the exception
that the flags
.Dv GLOB_ALTDIRFUNC ,
.Dv GLOB_BRACE ,
+.Dv GLOB_LIMIT ,
.Dv GLOB_MAGCHAR ,
-.Dv GLOB_MAXPATH ,
.Dv GLOB_NOMAGIC ,
.Dv GLOB_QUOTE ,
and
OpenPOWER on IntegriCloud