Commit 95ff1a41 authored by Simon Ruderich's avatar Simon Ruderich
Browse files

slsm: tree: don't match prefixes when searching for children

Before this commit all prefixes were considered matches.
parent b86b9d2e
......@@ -120,6 +120,16 @@ test_expect_success 'disallow exec access to /tmp/slsm' "
test_must_fail $BASH /tmp/slsm/test-me
"
test_expect_success 'correct matching for prefixes' "
test_when_finished cleanup && setup &&
touch /tmp/slsm/test-me &&
touch /tmp/slsm/test-me2 &&
\
rules p=/tmp/slsm/test-me2 m=0 &&
test_must_fail cat /tmp/slsm/test-me2 &&
cat /tmp/slsm/test-me
"
test_expect_success 'no circumvention via hardlinks' "
test_when_finished cleanup && setup &&
touch /tmp/slsm/test-me &&
......
......@@ -78,7 +78,8 @@ static struct tree_node *slsm_find_matching_child(const struct tree_node *t,
const char *path, size_t length) {
size_t i;
for (i = 0; i < t->children_used; i++) {
if (!strncmp(t->children[i].name, path, length))
if (!strncmp(t->children[i].name, path, length)
&& t->children[i].name[length] == '\0')
return &t->children[i];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment