diff --git a/ChangeLog b/ChangeLog index adc3faae8..cc9aa378e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ - (djm) Release 2.5.2p1 - tim@mindrot.org 2001/03/19 18:33:47 [defines.h] change S_ISLNK macro to work for UnixWare 2.03 +- tim@mindrot.org 2001/03/19 20:45:11 [openbsd-compat/glob.c] + add get_arg_max(). Use sysconf() if ARG_MAX is not defined 20010319 - (djm) Seed PRNG at startup, rather than waiting for arc4random calls to @@ -4643,4 +4645,4 @@ - Wrote replacements for strlcpy and mkdtemp - Released 1.0pre1 -$Id: ChangeLog,v 1.992 2001/03/20 02:31:44 tim Exp $ +$Id: ChangeLog,v 1.993 2001/03/20 04:46:50 tim Exp $ diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index 3c3a19131..5ed286211 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c @@ -37,6 +37,18 @@ #include "includes.h" #include +long +get_arg_max() +{ +#ifdef ARG_MAX + return(ARG_MAX); +#elif defined(HAVE_SYSCONF) && defined(_SC_ARG_MAX) + return(sysconf(_SC_ARG_MAX)); +#else + return(256); /* XXX: arbitrary */ +#endif +} + #if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ !defined(GLOB_HAS_GL_MATCHC) @@ -689,7 +701,7 @@ globextend(path, pglob, limitp) pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; if ((pglob->gl_flags & GLOB_LIMIT) && - newsize + *limitp >= ARG_MAX) { + newsize + *limitp >= (u_int) get_arg_max()) { errno = 0; return(GLOB_NOSPACE); }