X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fregex%2Fglob.c;h=5b6ff1247f437416e1a95dae05ba26f9e269fb91;hb=4ff234f6cba96403b5de6d29d48a59fd73252040;hp=6c07e6b3b5f817f57af09cd9e0a74a0d85bb0fc7;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/regex/glob.c b/src/regex/glob.c index 6c07e6b3..5b6ff124 100644 --- a/src/regex/glob.c +++ b/src/regex/glob.c @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include "libc.h" struct match @@ -171,8 +169,6 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i d = ""; } - if (strlen(p) > PATH_MAX) return GLOB_NOSPACE; - if (!errfunc) errfunc = ignore_err; if (!(flags & GLOB_APPEND)) { @@ -181,6 +177,8 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i g->gl_pathv = NULL; } + if (strnlen(p, PATH_MAX+1) > PATH_MAX) return GLOB_NOSPACE; + if (*p) error = match_in_dir(d, p, flags, errfunc, &tail); if (error == GLOB_NOSPACE) { freelist(&head);