diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/glob.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 | ||
40 | long | ||
41 | get_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 | } |