aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-05-22 16:59:11 -0700
committerSteve Kondik <steve@cyngn.com>2016-05-22 16:59:24 -0700
commit71ddd1fa5de0d97f57509172e20d5a1b7c081965 (patch)
tree014e4b645b9816f59a883c78f48ea2805e12f250
parent8aadde65f0b34e29946d37c00be050e762c7cd24 (diff)
downloadandroid_external_toybox-71ddd1fa5de0d97f57509172e20d5a1b7c081965.tar.gz
android_external_toybox-71ddd1fa5de0d97f57509172e20d5a1b7c081965.tar.bz2
android_external_toybox-71ddd1fa5de0d97f57509172e20d5a1b7c081965.zip
Revert "toybox: find: Fix segfault when using -iname/-ipath with -exec"
* Tom's patch was upstreamed. This reverts commit d5de71798489bf4cc2c1e89c0b0f2768a3b2ae47. Change-Id: I920566d757cf9748fbb472ab5cd44318876a2f8c
-rw-r--r--toys/posix/find.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 4c7e8647..303aada2 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -315,21 +315,22 @@ static int do_find(struct dirtree *new)
|| !strcmp(s, "path") || !strcmp(s, "ipath"))
{
int i = (*s == 'i');
-
- if (i && !new) {
- char *p;
- for (p = ss[1]; *p; ++p) {
- *p = tolower(*p);
- }
+ char *arg = ss[1], *path = 0, *name = new ? new->name : arg;
+
+ // Handle path expansion and case flattening
+ if (new && s[i] == 'p') name = path = dirtree_path(new, 0);
+ if (i) {
+ if (check || !new) {
+ if (name) name = strlower(name);
+ if (!new) {
+ dlist_add(&TT.argdata, name);
+ free(path);
+ } else arg = ((struct double_list *)llist_pop(&argdata))->data;
+ }
}
- if (check) {
- char *path = 0, *name = new->name;
-
- // Handle path expansion and case flattening
- if (s[i] == 'p') name = path = dirtree_path(new, 0);
- if (i) name = strlower(name);
- test = !fnmatch(ss[1], name, FNM_PATHNAME*(s[i] == 'p'));
+ if (check) {
+ test = !fnmatch(arg, name, FNM_PATHNAME*(s[i] == 'p'));
free(path);
if (i) free(name);
}