Marcel Moolenaar daab0b01ed Protect against DoS attacks, such as being described in CVE-2010-2632.
The changes were derived from what has been committed to NetBSD, with
modifications. These are:
1.  Preserve the existsing GLOB_LIMIT behaviour by including the number
    of matches to the set of parameters to limit.
2.  Change some of the limits to avoid impacting normal use cases:
    GLOB_LIMIT_STRING - change from 65536 to ARG_MAX so that glob(3)
	can still provide a full command line of expanded names.
    GLOB_LIMIT_STAT - change from 128 to 1024 for no other reason than
	that 128 feels too low (it's not a limit that impacts the
	behaviour of the test program listed in CVE-2010-2632).
    GLOB_LIMIT_PATH - change from 1024 to 65536 so that glob(3) can
	still provide a fill command line of expanded names.
3.  Protect against buffer overruns when we hit the GLOB_LIMIT_STAT or
    GLOB_LIMIT_READDIR limits. We append SEP and EOS to pathend in
    those cases. Return GLOB_ABORTED instead of GLOB_NOSPACE when we
    would otherwise overrun the buffer.

This change also modifies the existing behaviour of glob(3) in case
GLOB_LIMIT is specifies by limiting the *new* matches and not all
matches. This is an important distinction when GLOB_APPEND is set or
when the caller uses a non-zero gl_offs. Previously pre-existing
matches or the value of gl_offs would be counted in the number of
matches even though the man page states that glob(3) would return
GLOB_NOSPACE when gl_matchc or more matches were found.

The limits that cannot be circumvented are GLOB_LIMIT_STRING and
GLOB_LIMIT_PATH all others can be crossed by simply calling glob(3)
again and with GLOB_APPEND set.

The entire description above applies only when GLOB_LIMIT has been
specified of course. No limits apply when this flag isn't set!

Obtained from: Juniper Networks, Inc
2012-12-01 21:26:46 +00:00
..
2008-10-22 21:56:57 +00:00
2011-11-26 16:49:25 +00:00
2012-08-11 12:07:24 +00:00
2011-10-01 12:19:48 +00:00
2011-10-01 12:19:48 +00:00
2012-02-17 12:40:27 +00:00
2012-04-26 19:21:58 +00:00
2011-05-25 14:13:53 +00:00
2012-06-16 13:11:10 +00:00
2012-02-11 20:28:42 +00:00
2011-12-20 22:56:13 +00:00
2009-03-04 01:01:26 +00:00
2009-03-04 01:01:26 +00:00
2012-03-26 15:18:14 +00:00
2010-01-20 11:59:46 +00:00
2008-03-13 10:25:30 +00:00
2011-02-04 16:40:50 +00:00
2012-06-16 06:38:11 +00:00
2009-05-07 13:49:48 +00:00
2010-01-24 14:44:05 +00:00
2010-01-17 15:43:14 +00:00
2009-11-25 04:45:45 +00:00