aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-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) {