summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--openbsd-compat/glob.c14
2 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index adc3faae8..cc9aa378e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@
13 - (djm) Release 2.5.2p1 13 - (djm) Release 2.5.2p1
14- tim@mindrot.org 2001/03/19 18:33:47 [defines.h] 14- tim@mindrot.org 2001/03/19 18:33:47 [defines.h]
15 change S_ISLNK macro to work for UnixWare 2.03 15 change S_ISLNK macro to work for UnixWare 2.03
16- tim@mindrot.org 2001/03/19 20:45:11 [openbsd-compat/glob.c]
17 add get_arg_max(). Use sysconf() if ARG_MAX is not defined
16 18
1720010319 1920010319
18 - (djm) Seed PRNG at startup, rather than waiting for arc4random calls to 20 - (djm) Seed PRNG at startup, rather than waiting for arc4random calls to
@@ -4643,4 +4645,4 @@
4643 - Wrote replacements for strlcpy and mkdtemp 4645 - Wrote replacements for strlcpy and mkdtemp
4644 - Released 1.0pre1 4646 - Released 1.0pre1
4645 4647
4646$Id: ChangeLog,v 1.992 2001/03/20 02:31:44 tim Exp $ 4648$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 @@
37#include "includes.h" 37#include "includes.h"
38#include <ctype.h> 38#include <ctype.h>
39 39
40long
41get_arg_max()
42{
43#ifdef ARG_MAX
44 return(ARG_MAX);
45#elif defined(HAVE_SYSCONF) && defined(_SC_ARG_MAX)
46 return(sysconf(_SC_ARG_MAX));
47#else
48 return(256); /* XXX: arbitrary */
49#endif
50}
51
40#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ 52#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \
41 !defined(GLOB_HAS_GL_MATCHC) 53 !defined(GLOB_HAS_GL_MATCHC)
42 54
@@ -689,7 +701,7 @@ globextend(path, pglob, limitp)
689 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; 701 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
690 702
691 if ((pglob->gl_flags & GLOB_LIMIT) && 703 if ((pglob->gl_flags & GLOB_LIMIT) &&
692 newsize + *limitp >= ARG_MAX) { 704 newsize + *limitp >= (u_int) get_arg_max()) {
693 errno = 0; 705 errno = 0;
694 return(GLOB_NOSPACE); 706 return(GLOB_NOSPACE);
695 } 707 }