diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2009-02-11 13:24:06 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2009-02-11 13:24:06 +0000 |
commit | b4e2501bd8758b133e8e8637d0e14f5b53e637bd (patch) | |
tree | 07cda85d3fe1ad2d94d8332e006f0c0d8a88c7ef /lib/libc/gen | |
parent | 301625ba50094208e1d5bd3f0c42d6df775dec26 (diff) |
Avoid level going negative on deep (i mean really deep) dirs. Reported
by Maksymilian Arciemowicz. ok kettenis@ millert@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/fts.c | 10 |
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. */ |