summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2009-02-11 13:24:05 +0000
committerotto <otto@openbsd.org>2009-02-11 13:24:05 +0000
commit76fa785e0b0890d3a97745728a5d1133b5aafad8 (patch)
tree0d36ef9bd2d7fa5cca4907bf2f835abc24026c24
parentPrettier fake scsi inquiry ascii strings. (diff)
downloadwireguard-openbsd-76fa785e0b0890d3a97745728a5d1133b5aafad8.tar.xz
wireguard-openbsd-76fa785e0b0890d3a97745728a5d1133b5aafad8.zip
Avoid level going negative on deep (i mean really deep) dirs. Reported
by Maksymilian Arciemowicz. ok kettenis@ millert@
-rw-r--r--lib/libc/gen/fts.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index ae4bc3f5d1e..62b815fd2f0 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fts.c,v 1.41 2008/12/27 12:30:13 pedro Exp $ */
+/* $OpenBSD: fts.c,v 1.42 2009/02/11 13:24:05 otto Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -633,6 +633,14 @@ fts_build(FTS *sp, int type)
len++;
maxlen = sp->fts_pathlen - len;
+ if (cur->fts_level == SHRT_MAX) {
+ (void)closedir(dirp);
+ cur->fts_info = FTS_ERR;
+ SET(FTS_STOP);
+ errno = ENAMETOOLONG;
+ return (NULL);
+ }
+
level = cur->fts_level + 1;
/* Read the directory, attaching each entry to the `link' pointer. */