Date: 17 Jun 2001 11:17:45 +0200 From: Assar Westerlund <assar@freebsd.org> To: freebsd-audit@freebsd.org, jlemon@freebsd.org Subject: GLOB_LIMIT vs GLOB_MAXPATH Message-ID: <5ld783cvnq.fsf@assaris.sics.se>
index | next in thread | raw e-mail
[-- Attachment #1 --]
/assar
[-- Attachment #2 --]
Index: lib/libc/gen/glob.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.3,v
retrieving revision 1.15
diff -u -w -r1.15 glob.3
--- lib/libc/gen/glob.3 2001/03/19 19:10:06 1.15
+++ lib/libc/gen/glob.3 2001/06/17 00:12:41
@@ -260,13 +260,14 @@
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 .
+.Fa gl_matchc
+(default ARG_MAX).
If
.Fn glob
would match more pathnames,
-.Dv GLOB_LIMIT
+.Dv GLOB_LIMITHIT
will be returned.
.El
.Pp
@@ -384,9 +385,9 @@
was set or
.Fa \*(lp*errfunc\*(rp\*(lp\*(rp
returned non-zero.
-.It Dv GLOB_LIMIT
+.It Dv GLOB_LIMITHIT
The flag
-.Dv GLOB_MAXPATH
+.Dv GLOB_LIMIT
was provided, and the specified limit passed to
.Fn glob
in
Index: lib/libc/gen/glob.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.c,v
retrieving revision 1.17
diff -u -w -r1.17 glob.c
--- lib/libc/gen/glob.c 2001/03/28 23:55:51 1.17
+++ lib/libc/gen/glob.c 2001/06/17 00:12:49
@@ -170,9 +170,11 @@
if (!(flags & GLOB_DOOFFS))
pglob->gl_offs = 0;
}
- if (flags & GLOB_MAXPATH)
+ if (flags & GLOB_LIMIT) {
limit = pglob->gl_matchc;
- else
+ if (limit == 0)
+ limit = ARG_MAX;
+ } else
limit = 0;
pglob->gl_flags = flags & ~GLOB_MAGCHAR;
pglob->gl_errfunc = errfunc;
@@ -688,7 +690,7 @@
const Char *p;
if (*limit && pglob->gl_pathc > *limit)
- return (GLOB_LIMIT);
+ return (GLOB_LIMITHIT);
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
pathv = pglob->gl_pathv ?
Index: libexec/ftpd/ftpcmd.y
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpcmd.y,v
retrieving revision 1.26
diff -u -w -r1.26 ftpcmd.y
--- libexec/ftpd/ftpcmd.y 2001/04/28 07:55:19 1.26
+++ libexec/ftpd/ftpcmd.y 2001/06/17 00:15:15
@@ -947,7 +947,7 @@
GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
memset(&gl, 0, sizeof(gl));
- flags |= GLOB_MAXPATH;
+ flags |= GLOB_LIMIT;
gl.gl_matchc = MAXGLOBARGS;
if (glob($1, flags, NULL, &gl) ||
gl.gl_pathc == 0) {
Index: libexec/ftpd/ftpd.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.77
diff -u -w -r1.77 ftpd.c
--- libexec/ftpd/ftpd.c 2001/06/13 00:06:42 1.77
+++ libexec/ftpd/ftpd.c 2001/06/17 00:15:16
@@ -2670,7 +2670,7 @@
memset(&gl, 0, sizeof(gl));
gl.gl_matchc = MAXGLOBARGS;
- flags |= GLOB_MAXPATH;
+ flags |= GLOB_LIMIT;
freeglob = 1;
if (glob(whichf, flags, 0, &gl)) {
reply(550, "not found");
Index: libexec/ftpd/popen.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/popen.c,v
retrieving revision 1.20
diff -u -w -r1.20 popen.c
--- libexec/ftpd/popen.c 2001/03/19 19:11:00 1.20
+++ libexec/ftpd/popen.c 2001/06/17 00:15:16
@@ -108,7 +108,7 @@
memset(&gl, 0, sizeof(gl));
gl.gl_matchc = MAXGLOBARGS;
- flags |= GLOB_MAXPATH;
+ flags |= GLOB_LIMIT;
if (glob(argv[argc], flags, NULL, &gl))
gargv[gargc++] = strdup(argv[argc]);
else
Index: include/glob.h
===================================================================
RCS file: /home/ncvs/src/include/glob.h,v
retrieving revision 1.4
diff -u -w -r1.4 glob.h
--- include/glob.h 2001/03/19 19:10:06 1.4
+++ include/glob.h 2001/06/17 00:15:30
@@ -77,11 +77,11 @@
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
-#define GLOB_MAXPATH 0x1000 /* limit number of returned paths */
+#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABEND (-2) /* Unignored error. */
-#define GLOB_LIMIT (-3) /* Path limit was hit. */
+#define GLOB_LIMITHIT (-3) /* Path limit was hit. */
__BEGIN_DECLS
int glob __P((const char *, int, int (*)(const char *, int), glob_t *));
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5ld783cvnq.fsf>
