summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2001-03-19 20:49:46 -0800
committerTim Rice <tim@multitalents.net>2001-03-19 20:49:46 -0800
commit1da62f40ab8f2936c82dd083989f0f7990a724a2 (patch)
treef5b2f635ce84ebfce92c5124a72518fd99f46111
parentc17edda1c1d94860c723a47fbf88611d72401b7b (diff)
add get_arg_max(). Use sysconf() if ARG_MAX is not defined.
-rw-r--r--ChangeLog8
-rw-r--r--openbsd-compat/glob.c14
2 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f3bb97c4..219303a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,8 +11,10 @@
version 2.5.2
- (djm) Update RPM spec version
- (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 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.991.2.1 2001/03/20 02:49:21 tim Exp $
+$Id: ChangeLog,v 1.991.2.2 2001/03/20 04:49:46 tim Exp $
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c
index 3c3a1913..5ed28621 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -37,6 +37,18 @@
#include "includes.h"
#include <ctype.h>
+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);
}