aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/find.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-02-05 12:37:50 -0600
committerRob Landley <rob@landley.net>2016-02-05 12:37:50 -0600
commit0f11b42938f4ae32b2c80b1c0644b75e64da4ada (patch)
tree21e87a8800320b228ffb4d99dc953ec33455c06e /toys/posix/find.c
parent2fd8d1a2595ee49f01d2987b125b642b7f50ea65 (diff)
downloadtoybox-0f11b42938f4ae32b2c80b1c0644b75e64da4ada.tar.gz
Another fix from Josh Gao to avoid a null pointer dereference, and
minor cleanup of previous commit.
Diffstat (limited to 'toys/posix/find.c')
-rw-r--r--toys/posix/find.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 65beeb54..a9c35f41 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -315,14 +315,13 @@ static int do_find(struct dirtree *new)
|| !strcmp(s, "path") || !strcmp(s, "ipath"))
{
int i = (*s == 'i');
- char *arg = ss[1], *path = 0, *name = new->name;
+ 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) {
- char *temp = new ? name : arg;
- name = temp ? strlower(temp) : 0;
+ if (name) name = strlower(name);
if (!new) {
dlist_add(&TT.argdata, name);
free(path);