summaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2009-08-27 16:19:28 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2009-08-27 16:19:28 +0000
commitb7f5ad085124a99744ae40715274e883f8461659 (patch)
treef194ede5673cdb211dba854b336abc74df3abad7 /usr.bin/find
parentbf2e754350c1fb7e3b93a2dc42e445c7055f1d1e (diff)
Don't stop traversing a directory hierarchy if we reach SHRT_MAX,
just stop updating fts_level so we don't overflow it. This allows rm, find, etc to operate on very deep hierarchies. Consumers of fts(3) do need to be aware that the actual level may be larger than fts_level. During the next libc major bump we will make fts_level an int instead of a short. OK deraadt@
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/function.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 5f1dac45386..9b928eaf12b 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: function.c,v 1.31 2005/06/15 14:19:45 millert Exp $ */
+/* $OpenBSD: function.c,v 1.32 2009/08/27 16:19:27 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: function.c,v 1.31 2005/06/15 14:19:45 millert Exp $";
+static char rcsid[] = "$OpenBSD: function.c,v 1.32 2009/08/27 16:19:27 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -833,9 +833,12 @@ PLAN *
c_maxdepth(char *arg, char ***ignored, int unused)
{
PLAN *new;
+ const char *errstr = NULL;
new = palloc(N_MAXDEPTH, f_maxdepth);
- new->max_data = atoi(arg);
+ new->max_data = strtonum(arg, 1, FTS_MAXLEVEL, &errstr);
+ if (errstr)
+ errx(1, "%s: maxdepth value %s", arg, errstr);
return (new);
}