---
toys/posix/find.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
From 96ad8f5d25876907c43f7353cb759148ca959aec Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Sat, 9 Mar 2019 15:44:44 -0800
Subject: [PATCH] find: improve -context behavior on failure.
---
toys/posix/find.c | 9 +++++----
1 file 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) {
--
2.21.0.360.g471c308f928-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net