aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/find.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-03-09 15:44:44 -0800
committerRob Landley <rob@landley.net>2019-03-10 19:39:58 -0500
commit8b42e1ffd68adc8d000b3c2dfc1baccd926cbf01 (patch)
treeba7d85e5a364e8392a4a6fa5ae7c0e5b8b43f297 /toys/posix/find.c
parent0a4963242631c5424a1a3bca2b3092ff6bf54a6e (diff)
downloadtoybox-8b42e1ffd68adc8d000b3c2dfc1baccd926cbf01.tar.gz
find: improve -context behavior on failure.
Diffstat (limited to 'toys/posix/find.c')
-rw-r--r--toys/posix/find.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 7887c0a3..fdeb2048 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -350,12 +350,13 @@ static int do_find(struct dirtree *new)
free(path);
} else if (!CFG_TOYBOX_LSM_NONE && !strcmp(s, "context")) {
if (check) {
- char *path, *context;
+ char *path = dirtree_path(new, 0), *context;
- lsm_get_context(path = dirtree_path(new, 0), &context);
- test = !fnmatch(ss[1], context, 0);
+ if (lsm_get_context(path, &context) != -1) {
+ test = !fnmatch(ss[1], context, 0);
+ free(context);
+ } else test = 0;
free(path);
- free(context);
}
} else if (!strcmp(s, "perm")) {
if (check) {