2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Move pattern length check until after we have initialized the glob_t

so we can call globfree() even on error.  From Frank Denis.
This commit is contained in:
Todd C. Miller
2015-06-13 08:13:48 -06:00
parent 25917e435c
commit f43f530987

View File

@@ -203,9 +203,6 @@ sudo_glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
Char *bufnext, *bufend, patbuf[PATH_MAX];
struct glob_lim limit = { 0, 0, 0 };
if (strnlen(pattern, PATH_MAX) == PATH_MAX)
return GLOB_NOMATCH;
patnext = (unsigned char *) pattern;
if (!(flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
@@ -222,6 +219,9 @@ sudo_glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)
return GLOB_NOSPACE;
if (strnlen(pattern, PATH_MAX) == PATH_MAX)
return GLOB_NOMATCH;
bufnext = patbuf;
bufend = bufnext + PATH_MAX - 1;
if (flags & GLOB_NOESCAPE)