From owner-freebsd-stable Sat Mar 17 20:32:58 2001 Delivered-To: freebsd-stable@freebsd.org Received: from prism.flugsvamp.com (cb58709-a.mdsn1.wi.home.com [24.17.241.9]) by hub.freebsd.org (Postfix) with ESMTP id 01A1E37B71A for ; Sat, 17 Mar 2001 20:32:52 -0800 (PST) (envelope-from jlemon@flugsvamp.com) Received: (from jlemon@localhost) by prism.flugsvamp.com (8.11.0/8.11.0) id f2I4TIa17793; Sat, 17 Mar 2001 22:29:18 -0600 (CST) (envelope-from jlemon) Date: Sat, 17 Mar 2001 22:29:18 -0600 From: Jonathan Lemon To: Matt Dillon Cc: Jonathan Lemon , stable@freebsd.org Subject: Re: Not only ftpd's problem with ls */../*..... Message-ID: <20010317222918.B82645@prism.flugsvamp.com> References: <200103172253.f2HMrZ008412@prism.flugsvamp.com> <200103180027.f2I0RSn96769@earth.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: <200103180027.f2I0RSn96769@earth.backplane.com> Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, Mar 17, 2001 at 04:27:28PM -0800, Matt Dillon wrote: > :Yes, I'm considering the following: > : > : gl_flags |= GLOB_MAXFILES > : gl_match = filemax > : > :Since gl_match is only used as an input parameter at the moment. > :Another approach is to limit the number of bytes returned to ARG_MAX, > :but I somewhat dislike that; it makes more sense to me to specify the > :number of paths instead. > :-- > :Jonathan > > Hmm. Well, I like the idea of adding a flag to glob_t->flags but I > would prefer not to add another element to the glob_t structure > that would make it incompatible with existing programs. Remember the > mess changing FILE caused. Whups, the above was a typo, it should have been "gl_matchc". If you check the code, you will find that this field is already there, and used only as an output parameter. (Bah, I must have been really tired when I wrote the original paragraph, that's two mistakes). This means that there will be no backwards compatability problems and we don't have to change the structure size. > How about a combination of glob_t->flags and a global limit that can > be set with a new api call, setgloblimit()? Or perhaps even just > have the setgloblimit() API call and don't even bother with a new flag. I would think a better idea is to have the system default to a hard limit, and then allow those programs that know better to override it. This way, we catch most naive uses of glob, while allowing those users who actually want to iterate over more paths to continue. You'll also note that the glob interface explicitly allows continuing from a previous match (which is what gl_pathc is for), so this fits in nicely. The only additional change I can think of is to add a new error return to explicitly alert the user that the match limit was hit. Doing it this way also negates the need for a setgloblimit. > Remember when csh had an arbitrarily limit on command line length? > Things like 'foreach i ( `find . -type f` )' would fail arbitrarily. > Tcsh fixed that problem. Whatever we do, we do not want to reintroduce > this same sort of problem in other programs (whether shells do their own > globing or not). FYI, it seems that csh (and tcsh) use their own copy of glob, for reasons having to do with memory allocation. This copy will be getting a limit of ARG_MAX, from the last email that I've seen from Christos. -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message