History log of /openbsd-current/lib/libc/gen/glob.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.50 13-Oct-2020 guenther

Do some easy .data -> .rodata/.data.rel.ro conversions

ok millert@ deraadt@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.49 21-Apr-2020 dtucker

Prevent infinite for loop since i went from ssize_t to size_t. Patch from
eagleoflqj via OpenSSH github PR#178, ok djm@, feedback & ok millert@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.48 04-Feb-2019 millert

Make gl_pathc, gl_matchc and gl_offs size_t in glob_t to match POSIX.
This requires a libc major version bump. OK deraadt@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.47 08-May-2017 millert

Fix exponential CPU use with repeated '*' operators by changing '*'
handling to be interative instead of recursive.
Fix by Yves Orton, ported to OpenBSD glob.c by Ray Lai. OK tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.46 28-Dec-2015 mmcc

Remove NULL-checks before free() and a few related dead assignments.

ok and valuable input from millert@


# 1.45 24-Nov-2015 millert

Use reentrant versions of getpw{nam,uid} and getgr{nam,gid} within
libc to avoid reusing the static buffers returned by the non-reentrant
versions. Since this is inside libc we can use constants for the
buffer sizes instead of having to call sysconf().
OK guenther@ deraadt@


# 1.44 14-Sep-2015 tedu

remove null check before free. from Michael McConville
ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.43 13-Jun-2015 deraadt

in glob() initialize the glob_t before the first failure check.
from j@pureftpd.org
ok millert stsp


Revision tags: OPENBSD_5_7_BASE
# 1.42 05-Feb-2015 millert

Include stdint.h, not limits.h to get SIZE_MAX. OK guenther@


# 1.41 08-Oct-2014 deraadt

obvious realloc -> reallocarray conversion


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.40 30-Sep-2013 millert

Use PATH_MAX, NAME_MAX and LOGIN_NAME_MAX not MAXPATHNAMELEN,
MAXNAMLEN or MAXLOGNAME where possible. OK deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.39 20-Jan-2012 tedu

the glob stat limit is way too low. bump to 2048.
while here, failed stats should count against the limit too.
ok deraadt sthen stsp


# 1.38 22-Sep-2011 djm

fix GLOB_KEEPSTAT without GLOB_NOSORT; the implicit sort was being
applied only to the gl_pathv vector and not the corresponding gl_statv
array. reported in OpenSSH bz#1935; feedback and okay matthew@


# 1.37 20-Sep-2011 stsp

In glob(3), limit recursion during matching attempts. Similar to fnmatch fix.
Also collapse consecutive '*' (from NetBSD).
ok miod deraadt


Revision tags: OPENBSD_5_0_BASE
# 1.36 12-May-2011 pyr

When the max number of items for a directory has reached GLOB_LIMIT_READDIR
an error is returned but closedir() is not called.

spotted and fix provided by Frank Denis obsd-tech@pureftpd.org

ok otto@, millert@


Revision tags: OPENBSD_4_9_BASE
# 1.35 12-Jan-2011 djm

avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
and sanity check arguments (these will be unnecessary when we switch
struct glob members from being type into to size_t in the future);
"looks ok" tedu@ feedback guenther@


# 1.34 08-Oct-2010 nicm

Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
from ARG_MAX to 64K.

Fixes glob-using programs (notably ftp) able to be triggered to hit
resource limits.

Idea from a similar NetBSD change, original problem reported by jasper@.

ok millert tedu jasper


# 1.33 26-Sep-2010 djm

oops, don't free array before freeing members; spotted by dkrause@


# 1.32 24-Sep-2010 djm

add a GLOB_KEEPSTAT option that retains a copy of the struct stat
information that is looked up while matching glob(3)s

Keeping this information around can make a big difference when
fetching it is expensive, e.g. in sftp which uses GLOB_ALTDIRFUNC

feedback millert@ jmc@

"get it in before the libc crank" deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.31 19-May-2010 chl

remove unused variable

ok nicm@


# 1.30 23-Mar-2010 nicm

Fix glob(3) to correctly return an error when its buffer space is
exhausted and GLOB_BRACE is given. globexp2() was ignoring errors
returned from lower levels.

While here, change globexp2() to return its return value normally rather
putting it in a int pointer then always returning 0.

ok otto


Revision tags: OPENBSD_4_7_BASE
# 1.29 21-Nov-2009 chl

replacing malloc/realloc dance, by only one realloc

ok millert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.28 18-Feb-2009 millert

Add missing braces. This is why we use braces for indented block that
are more than a couple of lines...


# 1.27 01-Oct-2008 millert

POSIX character class support for fnmatch(3) and glob(3). OK deraadt@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.26 28-Nov-2005 deraadt

unused arg in internal static API


Revision tags: OPENBSD_3_8_BASE
# 1.25 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.24 07-Oct-2004 millert

Kill register and fix some whilespace goofs in a do {} while loop.


Revision tags: OPENBSD_3_6_BASE
# 1.23 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 25-Jun-2003 deraadt

protos


# 1.21 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


# 1.19 24-May-2002 deraadt

try to use strlcpy and snprintf more; ok various


Revision tags: OPENBSD_3_1_BASE
# 1.18 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.17 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.16 05-Apr-2001 deraadt

remove extra continue statements


# 1.15 02-Apr-2001 deraadt

use a len in g_Ctoc, easier code; freebsd


# 1.14 28-Mar-2001 millert

Fix some glob defects:
o use MAXPATHLEN, not MAXPATHLEN + 1
o when manipulating static buffers, pass functions a pointer to
the end of the buffer so we can avoid any overflows

Work by Theo and myself.


# 1.13 28-Mar-2001 deraadt

must spec +1 in this one case...


# 1.12 28-Mar-2001 deraadt

avoid g_Ctoc() overflows; art@ ok


# 1.11 28-Mar-2001 deraadt

KNF


# 1.10 19-Mar-2001 millert

set gl_pathv to NULL after we free it; christos@netbsd.org


# 1.9 18-Mar-2001 deraadt

GLOB_LIMIT changes from christos


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 14-Aug-1998 deraadt

branches: 1.8.10;
realloc repair


Revision tags: OPENBSD_2_3_BASE
# 1.7 31-Jan-1998 millert

Add GLOB_NOESCAPE to turn off backslash escaping and make backslash escaping
the default. For xpg4.2.


Revision tags: OPENBSD_2_2_BASE
# 1.6 01-Sep-1997 millert

Make glob(3) XPG4.2 compliant. This means changing GLOB_ABEND to
GLOB_ABORT and defining GLOB_NOMATCH and GLOB_NOSYS (the latter is
not used).


Revision tags: OPENBSD_2_1_BASE
# 1.5 12-Apr-1997 millert

Different fix for buffer overflow. From Keith Bostic <bostic@bostic.com>


# 1.4 27-Oct-1996 deraadt

be careful in the non-setuid case too, what the heck


Revision tags: OPENBSD_2_0_BASE
# 1.3 11-Sep-1996 deraadt

protect $HOME expansion; from das33@cornell.edu


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.49 21-Apr-2020 dtucker

Prevent infinite for loop since i went from ssize_t to size_t. Patch from
eagleoflqj via OpenSSH github PR#178, ok djm@, feedback & ok millert@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.48 04-Feb-2019 millert

Make gl_pathc, gl_matchc and gl_offs size_t in glob_t to match POSIX.
This requires a libc major version bump. OK deraadt@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.47 08-May-2017 millert

Fix exponential CPU use with repeated '*' operators by changing '*'
handling to be interative instead of recursive.
Fix by Yves Orton, ported to OpenBSD glob.c by Ray Lai. OK tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.46 28-Dec-2015 mmcc

Remove NULL-checks before free() and a few related dead assignments.

ok and valuable input from millert@


# 1.45 24-Nov-2015 millert

Use reentrant versions of getpw{nam,uid} and getgr{nam,gid} within
libc to avoid reusing the static buffers returned by the non-reentrant
versions. Since this is inside libc we can use constants for the
buffer sizes instead of having to call sysconf().
OK guenther@ deraadt@


# 1.44 14-Sep-2015 tedu

remove null check before free. from Michael McConville
ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.43 13-Jun-2015 deraadt

in glob() initialize the glob_t before the first failure check.
from j@pureftpd.org
ok millert stsp


Revision tags: OPENBSD_5_7_BASE
# 1.42 05-Feb-2015 millert

Include stdint.h, not limits.h to get SIZE_MAX. OK guenther@


# 1.41 08-Oct-2014 deraadt

obvious realloc -> reallocarray conversion


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.40 30-Sep-2013 millert

Use PATH_MAX, NAME_MAX and LOGIN_NAME_MAX not MAXPATHNAMELEN,
MAXNAMLEN or MAXLOGNAME where possible. OK deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.39 20-Jan-2012 tedu

the glob stat limit is way too low. bump to 2048.
while here, failed stats should count against the limit too.
ok deraadt sthen stsp


# 1.38 22-Sep-2011 djm

fix GLOB_KEEPSTAT without GLOB_NOSORT; the implicit sort was being
applied only to the gl_pathv vector and not the corresponding gl_statv
array. reported in OpenSSH bz#1935; feedback and okay matthew@


# 1.37 20-Sep-2011 stsp

In glob(3), limit recursion during matching attempts. Similar to fnmatch fix.
Also collapse consecutive '*' (from NetBSD).
ok miod deraadt


Revision tags: OPENBSD_5_0_BASE
# 1.36 12-May-2011 pyr

When the max number of items for a directory has reached GLOB_LIMIT_READDIR
an error is returned but closedir() is not called.

spotted and fix provided by Frank Denis obsd-tech@pureftpd.org

ok otto@, millert@


Revision tags: OPENBSD_4_9_BASE
# 1.35 12-Jan-2011 djm

avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
and sanity check arguments (these will be unnecessary when we switch
struct glob members from being type into to size_t in the future);
"looks ok" tedu@ feedback guenther@


# 1.34 08-Oct-2010 nicm

Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
from ARG_MAX to 64K.

Fixes glob-using programs (notably ftp) able to be triggered to hit
resource limits.

Idea from a similar NetBSD change, original problem reported by jasper@.

ok millert tedu jasper


# 1.33 26-Sep-2010 djm

oops, don't free array before freeing members; spotted by dkrause@


# 1.32 24-Sep-2010 djm

add a GLOB_KEEPSTAT option that retains a copy of the struct stat
information that is looked up while matching glob(3)s

Keeping this information around can make a big difference when
fetching it is expensive, e.g. in sftp which uses GLOB_ALTDIRFUNC

feedback millert@ jmc@

"get it in before the libc crank" deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.31 19-May-2010 chl

remove unused variable

ok nicm@


# 1.30 23-Mar-2010 nicm

Fix glob(3) to correctly return an error when its buffer space is
exhausted and GLOB_BRACE is given. globexp2() was ignoring errors
returned from lower levels.

While here, change globexp2() to return its return value normally rather
putting it in a int pointer then always returning 0.

ok otto


Revision tags: OPENBSD_4_7_BASE
# 1.29 21-Nov-2009 chl

replacing malloc/realloc dance, by only one realloc

ok millert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.28 18-Feb-2009 millert

Add missing braces. This is why we use braces for indented block that
are more than a couple of lines...


# 1.27 01-Oct-2008 millert

POSIX character class support for fnmatch(3) and glob(3). OK deraadt@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.26 28-Nov-2005 deraadt

unused arg in internal static API


Revision tags: OPENBSD_3_8_BASE
# 1.25 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.24 07-Oct-2004 millert

Kill register and fix some whilespace goofs in a do {} while loop.


Revision tags: OPENBSD_3_6_BASE
# 1.23 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 25-Jun-2003 deraadt

protos


# 1.21 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


# 1.19 24-May-2002 deraadt

try to use strlcpy and snprintf more; ok various


Revision tags: OPENBSD_3_1_BASE
# 1.18 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.17 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.16 05-Apr-2001 deraadt

remove extra continue statements


# 1.15 02-Apr-2001 deraadt

use a len in g_Ctoc, easier code; freebsd


# 1.14 28-Mar-2001 millert

Fix some glob defects:
o use MAXPATHLEN, not MAXPATHLEN + 1
o when manipulating static buffers, pass functions a pointer to
the end of the buffer so we can avoid any overflows

Work by Theo and myself.


# 1.13 28-Mar-2001 deraadt

must spec +1 in this one case...


# 1.12 28-Mar-2001 deraadt

avoid g_Ctoc() overflows; art@ ok


# 1.11 28-Mar-2001 deraadt

KNF


# 1.10 19-Mar-2001 millert

set gl_pathv to NULL after we free it; christos@netbsd.org


# 1.9 18-Mar-2001 deraadt

GLOB_LIMIT changes from christos


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 14-Aug-1998 deraadt

branches: 1.8.10;
realloc repair


Revision tags: OPENBSD_2_3_BASE
# 1.7 31-Jan-1998 millert

Add GLOB_NOESCAPE to turn off backslash escaping and make backslash escaping
the default. For xpg4.2.


Revision tags: OPENBSD_2_2_BASE
# 1.6 01-Sep-1997 millert

Make glob(3) XPG4.2 compliant. This means changing GLOB_ABEND to
GLOB_ABORT and defining GLOB_NOMATCH and GLOB_NOSYS (the latter is
not used).


Revision tags: OPENBSD_2_1_BASE
# 1.5 12-Apr-1997 millert

Different fix for buffer overflow. From Keith Bostic <bostic@bostic.com>


# 1.4 27-Oct-1996 deraadt

be careful in the non-setuid case too, what the heck


Revision tags: OPENBSD_2_0_BASE
# 1.3 11-Sep-1996 deraadt

protect $HOME expansion; from das33@cornell.edu


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.48 04-Feb-2019 millert

Make gl_pathc, gl_matchc and gl_offs size_t in glob_t to match POSIX.
This requires a libc major version bump. OK deraadt@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.47 08-May-2017 millert

Fix exponential CPU use with repeated '*' operators by changing '*'
handling to be interative instead of recursive.
Fix by Yves Orton, ported to OpenBSD glob.c by Ray Lai. OK tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.46 28-Dec-2015 mmcc

Remove NULL-checks before free() and a few related dead assignments.

ok and valuable input from millert@


# 1.45 24-Nov-2015 millert

Use reentrant versions of getpw{nam,uid} and getgr{nam,gid} within
libc to avoid reusing the static buffers returned by the non-reentrant
versions. Since this is inside libc we can use constants for the
buffer sizes instead of having to call sysconf().
OK guenther@ deraadt@


# 1.44 14-Sep-2015 tedu

remove null check before free. from Michael McConville
ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.43 13-Jun-2015 deraadt

in glob() initialize the glob_t before the first failure check.
from j@pureftpd.org
ok millert stsp


Revision tags: OPENBSD_5_7_BASE
# 1.42 05-Feb-2015 millert

Include stdint.h, not limits.h to get SIZE_MAX. OK guenther@


# 1.41 08-Oct-2014 deraadt

obvious realloc -> reallocarray conversion


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.40 30-Sep-2013 millert

Use PATH_MAX, NAME_MAX and LOGIN_NAME_MAX not MAXPATHNAMELEN,
MAXNAMLEN or MAXLOGNAME where possible. OK deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.39 20-Jan-2012 tedu

the glob stat limit is way too low. bump to 2048.
while here, failed stats should count against the limit too.
ok deraadt sthen stsp


# 1.38 22-Sep-2011 djm

fix GLOB_KEEPSTAT without GLOB_NOSORT; the implicit sort was being
applied only to the gl_pathv vector and not the corresponding gl_statv
array. reported in OpenSSH bz#1935; feedback and okay matthew@


# 1.37 20-Sep-2011 stsp

In glob(3), limit recursion during matching attempts. Similar to fnmatch fix.
Also collapse consecutive '*' (from NetBSD).
ok miod deraadt


Revision tags: OPENBSD_5_0_BASE
# 1.36 12-May-2011 pyr

When the max number of items for a directory has reached GLOB_LIMIT_READDIR
an error is returned but closedir() is not called.

spotted and fix provided by Frank Denis obsd-tech@pureftpd.org

ok otto@, millert@


Revision tags: OPENBSD_4_9_BASE
# 1.35 12-Jan-2011 djm

avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
and sanity check arguments (these will be unnecessary when we switch
struct glob members from being type into to size_t in the future);
"looks ok" tedu@ feedback guenther@


# 1.34 08-Oct-2010 nicm

Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
from ARG_MAX to 64K.

Fixes glob-using programs (notably ftp) able to be triggered to hit
resource limits.

Idea from a similar NetBSD change, original problem reported by jasper@.

ok millert tedu jasper


# 1.33 26-Sep-2010 djm

oops, don't free array before freeing members; spotted by dkrause@


# 1.32 24-Sep-2010 djm

add a GLOB_KEEPSTAT option that retains a copy of the struct stat
information that is looked up while matching glob(3)s

Keeping this information around can make a big difference when
fetching it is expensive, e.g. in sftp which uses GLOB_ALTDIRFUNC

feedback millert@ jmc@

"get it in before the libc crank" deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.31 19-May-2010 chl

remove unused variable

ok nicm@


# 1.30 23-Mar-2010 nicm

Fix glob(3) to correctly return an error when its buffer space is
exhausted and GLOB_BRACE is given. globexp2() was ignoring errors
returned from lower levels.

While here, change globexp2() to return its return value normally rather
putting it in a int pointer then always returning 0.

ok otto


Revision tags: OPENBSD_4_7_BASE
# 1.29 21-Nov-2009 chl

replacing malloc/realloc dance, by only one realloc

ok millert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.28 18-Feb-2009 millert

Add missing braces. This is why we use braces for indented block that
are more than a couple of lines...


# 1.27 01-Oct-2008 millert

POSIX character class support for fnmatch(3) and glob(3). OK deraadt@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.26 28-Nov-2005 deraadt

unused arg in internal static API


Revision tags: OPENBSD_3_8_BASE
# 1.25 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.24 07-Oct-2004 millert

Kill register and fix some whilespace goofs in a do {} while loop.


Revision tags: OPENBSD_3_6_BASE
# 1.23 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 25-Jun-2003 deraadt

protos


# 1.21 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


# 1.19 24-May-2002 deraadt

try to use strlcpy and snprintf more; ok various


Revision tags: OPENBSD_3_1_BASE
# 1.18 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.17 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.16 05-Apr-2001 deraadt

remove extra continue statements


# 1.15 02-Apr-2001 deraadt

use a len in g_Ctoc, easier code; freebsd


# 1.14 28-Mar-2001 millert

Fix some glob defects:
o use MAXPATHLEN, not MAXPATHLEN + 1
o when manipulating static buffers, pass functions a pointer to
the end of the buffer so we can avoid any overflows

Work by Theo and myself.


# 1.13 28-Mar-2001 deraadt

must spec +1 in this one case...


# 1.12 28-Mar-2001 deraadt

avoid g_Ctoc() overflows; art@ ok


# 1.11 28-Mar-2001 deraadt

KNF


# 1.10 19-Mar-2001 millert

set gl_pathv to NULL after we free it; christos@netbsd.org


# 1.9 18-Mar-2001 deraadt

GLOB_LIMIT changes from christos


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 14-Aug-1998 deraadt

branches: 1.8.10;
realloc repair


Revision tags: OPENBSD_2_3_BASE
# 1.7 31-Jan-1998 millert

Add GLOB_NOESCAPE to turn off backslash escaping and make backslash escaping
the default. For xpg4.2.


Revision tags: OPENBSD_2_2_BASE
# 1.6 01-Sep-1997 millert

Make glob(3) XPG4.2 compliant. This means changing GLOB_ABEND to
GLOB_ABORT and defining GLOB_NOMATCH and GLOB_NOSYS (the latter is
not used).


Revision tags: OPENBSD_2_1_BASE
# 1.5 12-Apr-1997 millert

Different fix for buffer overflow. From Keith Bostic <bostic@bostic.com>


# 1.4 27-Oct-1996 deraadt

be careful in the non-setuid case too, what the heck


Revision tags: OPENBSD_2_0_BASE
# 1.3 11-Sep-1996 deraadt

protect $HOME expansion; from das33@cornell.edu


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.47 08-May-2017 millert

Fix exponential CPU use with repeated '*' operators by changing '*'
handling to be interative instead of recursive.
Fix by Yves Orton, ported to OpenBSD glob.c by Ray Lai. OK tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.46 28-Dec-2015 mmcc

Remove NULL-checks before free() and a few related dead assignments.

ok and valuable input from millert@


# 1.45 24-Nov-2015 millert

Use reentrant versions of getpw{nam,uid} and getgr{nam,gid} within
libc to avoid reusing the static buffers returned by the non-reentrant
versions. Since this is inside libc we can use constants for the
buffer sizes instead of having to call sysconf().
OK guenther@ deraadt@


# 1.44 14-Sep-2015 tedu

remove null check before free. from Michael McConville
ok semarie


Revision tags: OPENBSD_5_8_BASE
# 1.43 13-Jun-2015 deraadt

in glob() initialize the glob_t before the first failure check.
from j@pureftpd.org
ok millert stsp


Revision tags: OPENBSD_5_7_BASE
# 1.42 05-Feb-2015 millert

Include stdint.h, not limits.h to get SIZE_MAX. OK guenther@


# 1.41 08-Oct-2014 deraadt

obvious realloc -> reallocarray conversion


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.40 30-Sep-2013 millert

Use PATH_MAX, NAME_MAX and LOGIN_NAME_MAX not MAXPATHNAMELEN,
MAXNAMLEN or MAXLOGNAME where possible. OK deraadt@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.39 20-Jan-2012 tedu

the glob stat limit is way too low. bump to 2048.
while here, failed stats should count against the limit too.
ok deraadt sthen stsp


# 1.38 22-Sep-2011 djm

fix GLOB_KEEPSTAT without GLOB_NOSORT; the implicit sort was being
applied only to the gl_pathv vector and not the corresponding gl_statv
array. reported in OpenSSH bz#1935; feedback and okay matthew@


# 1.37 20-Sep-2011 stsp

In glob(3), limit recursion during matching attempts. Similar to fnmatch fix.
Also collapse consecutive '*' (from NetBSD).
ok miod deraadt


Revision tags: OPENBSD_5_0_BASE
# 1.36 12-May-2011 pyr

When the max number of items for a directory has reached GLOB_LIMIT_READDIR
an error is returned but closedir() is not called.

spotted and fix provided by Frank Denis obsd-tech@pureftpd.org

ok otto@, millert@


Revision tags: OPENBSD_4_9_BASE
# 1.35 12-Jan-2011 djm

avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
and sanity check arguments (these will be unnecessary when we switch
struct glob members from being type into to size_t in the future);
"looks ok" tedu@ feedback guenther@


# 1.34 08-Oct-2010 nicm

Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
from ARG_MAX to 64K.

Fixes glob-using programs (notably ftp) able to be triggered to hit
resource limits.

Idea from a similar NetBSD change, original problem reported by jasper@.

ok millert tedu jasper


# 1.33 26-Sep-2010 djm

oops, don't free array before freeing members; spotted by dkrause@


# 1.32 24-Sep-2010 djm

add a GLOB_KEEPSTAT option that retains a copy of the struct stat
information that is looked up while matching glob(3)s

Keeping this information around can make a big difference when
fetching it is expensive, e.g. in sftp which uses GLOB_ALTDIRFUNC

feedback millert@ jmc@

"get it in before the libc crank" deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.31 19-May-2010 chl

remove unused variable

ok nicm@


# 1.30 23-Mar-2010 nicm

Fix glob(3) to correctly return an error when its buffer space is
exhausted and GLOB_BRACE is given. globexp2() was ignoring errors
returned from lower levels.

While here, change globexp2() to return its return value normally rather
putting it in a int pointer then always returning 0.

ok otto


Revision tags: OPENBSD_4_7_BASE
# 1.29 21-Nov-2009 chl

replacing malloc/realloc dance, by only one realloc

ok millert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.28 18-Feb-2009 millert

Add missing braces. This is why we use braces for indented block that
are more than a couple of lines...


# 1.27 01-Oct-2008 millert

POSIX character class support for fnmatch(3) and glob(3). OK deraadt@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.26 28-Nov-2005 deraadt

unused arg in internal static API


Revision tags: OPENBSD_3_8_BASE
# 1.25 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.24 07-Oct-2004 millert

Kill register and fix some whilespace goofs in a do {} while loop.


Revision tags: OPENBSD_3_6_BASE
# 1.23 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 25-Jun-2003 deraadt

protos


# 1.21 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


# 1.19 24-May-2002 deraadt

try to use strlcpy and snprintf more; ok various


Revision tags: OPENBSD_3_1_BASE
# 1.18 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.17 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.16 05-Apr-2001 deraadt

remove extra continue statements


# 1.15 02-Apr-2001 deraadt

use a len in g_Ctoc, easier code; freebsd


# 1.14 28-Mar-2001 millert

Fix some glob defects:
o use MAXPATHLEN, not MAXPATHLEN + 1
o when manipulating static buffers, pass functions a pointer to
the end of the buffer so we can avoid any overflows

Work by Theo and myself.


# 1.13 28-Mar-2001 deraadt

must spec +1 in this one case...


# 1.12 28-Mar-2001 deraadt

avoid g_Ctoc() overflows; art@ ok


# 1.11 28-Mar-2001 deraadt

KNF


# 1.10 19-Mar-2001 millert

set gl_pathv to NULL after we free it; christos@netbsd.org


# 1.9 18-Mar-2001 deraadt

GLOB_LIMIT changes from christos


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 14-Aug-1998 deraadt

branches: 1.8.10;
realloc repair


Revision tags: OPENBSD_2_3_BASE
# 1.7 31-Jan-1998 millert

Add GLOB_NOESCAPE to turn off backslash escaping and make backslash escaping
the default. For xpg4.2.


Revision tags: OPENBSD_2_2_BASE
# 1.6 01-Sep-1997 millert

Make glob(3) XPG4.2 compliant. This means changing GLOB_ABEND to
GLOB_ABORT and defining GLOB_NOMATCH and GLOB_NOSYS (the latter is
not used).


Revision tags: OPENBSD_2_1_BASE
# 1.5 12-Apr-1997 millert

Different fix for buffer overflow. From Keith Bostic <bostic@bostic.com>


# 1.4 27-Oct-1996 deraadt

be careful in the non-setuid case too, what the heck


Revision tags: OPENBSD_2_0_BASE
# 1.3 11-Sep-1996 deraadt

protect $HOME expansion; from das33@cornell.edu


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision