summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-06-13 16:57:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-06-13 16:57:05 +0000
commite1681d911983df844410942bdc702b4b0785aad1 (patch)
treebfcd8c815f0d9d1a60150c4d1d59832c887439ca /lib
parent38ad0842e290a423e969ec9ce8f033a08ca83149 (diff)
in glob() initialize the glob_t before the first failure check.
from j@pureftpd.org ok millert stsp
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/glob.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index a046ed6a377..27003b3be99 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glob.c,v 1.42 2015/02/05 12:59:57 millert Exp $ */
+/* $OpenBSD: glob.c,v 1.43 2015/06/13 16:57:04 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -175,9 +175,6 @@ 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 = (u_char *) pattern;
if (!(flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
@@ -190,6 +187,9 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
pglob->gl_errfunc = errfunc;
pglob->gl_matchc = 0;
+ if (strnlen(pattern, PATH_MAX) == PATH_MAX)
+ return(GLOB_NOMATCH);
+
if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 ||
pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)