summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorJonathan Lemon <jlemon@FreeBSD.org>2001-03-16 19:18:10 +0000
committerJonathan Lemon <jlemon@FreeBSD.org>2001-03-16 19:18:10 +0000
commit419ad7f632672ed00bdb88fbcd4f054dba99c9ce (patch)
tree96460b12e0a67edc24507c365d31f2ef8c8a418d /lib/libc
parent82c5aaa3ac9e4a482e4604f0b7afb52b74f77dcc (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/glob.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index 09dfd7a7cb54..5ed8be45f365 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -32,6 +32,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -78,6 +80,14 @@ static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
#include "collate.h"
+/*
+ * XXX
+ * Arbitrarily limit the number of pathnames that glob may
+ * return, to prevent DoS attacks. This should probably be
+ * configurable by the user.
+ */
+#define MAX_GLOBENTRIES 16384
+
#define DOLLAR '$'
#define DOT '.'
#define EOS '\0'
@@ -658,6 +668,9 @@ globextend(path, pglob)
char *copy;
const Char *p;
+ if (pglob->gl_pathc > MAX_GLOBENTRIES)
+ return (GLOB_ABEND);
+
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
pathv = pglob->gl_pathv ?
realloc((char *)pglob->gl_pathv, newsize) :