summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2019-11-15 16:02:27 +1100
committerDamien Miller <djm@mindrot.org>2019-11-15 16:02:27 +1100
commitfd37cdeafe25adfcdc752280f535d28de7997ff1 (patch)
treec5e80b2910ada719f68421e1257c61ce15ba5744 /openbsd-compat
parentfd62769c3882adea118dccaff80a06009874a2d1 (diff)
upstream commit
revision 1.43 date: 2015/06/13 16:57:04; author: deraadt; state: Exp; lines: +4 -4; commitid: zOUKuqWBdOPOz1SZ; in glob() initialize the glob_t before the first failure check. from j@pureftpd.org ok millert stsp
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/glob.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c
index e90265971..d4e052fa0 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: glob.c,v 1.42 2015/02/05 12:59:57 millert Exp $ */ 1/* $OpenBSD: glob.c,v 1.43 2015/06/13 16:57:04 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 1989, 1993 3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
@@ -186,9 +186,6 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
186 Char *bufnext, *bufend, patbuf[PATH_MAX]; 186 Char *bufnext, *bufend, patbuf[PATH_MAX];
187 struct glob_lim limit = { 0, 0, 0 }; 187 struct glob_lim limit = { 0, 0, 0 };
188 188
189 if (strnlen(pattern, PATH_MAX) == PATH_MAX)
190 return(GLOB_NOMATCH);
191
192 patnext = (u_char *) pattern; 189 patnext = (u_char *) pattern;
193 if (!(flags & GLOB_APPEND)) { 190 if (!(flags & GLOB_APPEND)) {
194 pglob->gl_pathc = 0; 191 pglob->gl_pathc = 0;
@@ -201,6 +198,9 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
201 pglob->gl_errfunc = errfunc; 198 pglob->gl_errfunc = errfunc;
202 pglob->gl_matchc = 0; 199 pglob->gl_matchc = 0;
203 200
201 if (strnlen(pattern, PATH_MAX) == PATH_MAX)
202 return(GLOB_NOMATCH);
203
204 if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 || 204 if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 ||
205 pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX || 205 pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
206 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1) 206 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)