aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-01-02 14:24:56 -0600
committerRob Landley <rob@landley.net>2016-01-02 14:24:56 -0600
commitaa784b09a9fbbbd571130051405edeaea7c9b510 (patch)
tree63241993c5b872d96fb472731015f91f9cc09720 /toys/posix
parent7b746d26f5134fc3fe805443187177656b24036e (diff)
downloadtoybox-aa784b09a9fbbbd571130051405edeaea7c9b510.tar.gz
Fix "find . -exec echo {}" segfault, and stop measuring environment space,
The segfault was spotted/fixed by Daniel K. Levy back in September, and again by Isabella Parakiss yesterday. While we're there, remove the environment size measurement code (the 128k limit was lifted by linux commit b6a2fea39318, which went into 2.6.22 released July 2007).
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/find.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 1e748feb..767b4009 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -55,7 +55,7 @@ config FIND
GLOBALS(
char **filter;
struct double_list *argdata;
- int topdir, xdev, depth, envsize;
+ int topdir, xdev, depth;
time_t now;
)
@@ -63,7 +63,7 @@ GLOBALS(
struct exec_range {
char *next, *prev;
- int dir, plus, arglen, argsize, curly, namecount, namesize;
+ int dir, plus, arglen, argsize, curly, namecount;
char **argstart;
struct double_list *names;
};
@@ -387,16 +387,7 @@ static int do_find(struct dirtree *new)
if (!strcmp(ss[len], ";")) break;
else if (!strcmp(ss[len], "{}")) {
aa->curly = len;
- if (!strcmp(ss[len+1], "+")) {
-
- // Measure environment space
- if (!TT.envsize) {
- char **env;
-
- for (env = environ; *env; env++)
- TT.envsize += sizeof(char *) + strlen(*env) + 1;
- TT.envsize += sizeof(char *);
- }
+ if (ss[len+1] && !strcmp(ss[len+1], "+")) {
aa->plus++;
len++;
break;
@@ -439,17 +430,6 @@ static int do_find(struct dirtree *new)
ddl = (struct double_list **)&new->parent->extra;
else ddl = &aa->names;
- // Is this + mode?
- if (aa->plus) {
- int size = sizeof(char *)+strlen(name)+1;
-
- // Linux caps environment space (env vars + args) at 32 4k pages.
- // todo: is there a way to probe this instead of constant here?
-
- if (TT.envsize+aa->argsize+aa->namesize+size >= 131072)
- toys.exitval |= flush_exec(new, aa);
- aa->namesize += size;
- }
dlist_add(ddl, name);
aa->namecount++;
if (!aa->plus) test = flush_exec(new, aa);