Commit e13159c2 authored by Lukas Braun's avatar Lukas Braun Committed by Simon Ruderich
Browse files

slsm: treat empty optional arguments as non-existent

Gets rid of a special case in slsm_serialize_subtree.
parent c98b6b83
......@@ -237,20 +237,13 @@ ssize_t slsm_serialize_subtree(struct slsm_str *buf, struct slsm_str *path_buf,
return ret;
for (i = 0; i < t->rules_used; i++) {
ret = slsm_str_append(buf, "p=%s%cm=%u%cf=%u%c",
ret = slsm_str_append(buf, "p=%s%ca=%s%cm=%u%cf=%u%c",
path_buf->buf, '\0',
t->rules[i].app, '\0',
t->rules[i].perms.mode, '\0',
t->rules[i].perms.flags, '\0');
if (ret)
return ret;
// TODO: get rid of this special case by handling a=\0 in the parser
if (t->rules[i].app) {
buf->used--; // remove second trailing null byte
ret = slsm_str_append(buf, "a=%s%c", t->rules[i].app, '\0');
if (ret)
return ret;
}
}
// exclude null for the recursive calls
......@@ -501,7 +494,8 @@ insert:
mode_str);
return error;
}
if (flags_str && (error = kstrtouint(flags_str, 10, &r.perms.flags))) {
if (flags_str && *flags_str
&& (error = kstrtouint(flags_str, 10, &r.perms.flags))) {
printk(KERN_ERR "slsm_insert_rule: format error: flags not a number: %s\n",
flags_str);
return error;
......@@ -511,7 +505,7 @@ insert:
if (!path_components)
return -ENOMEM;
if (app) {
if (app && *app) {
r.app = kstrdup(app, GFP_KERNEL);
if (!r.app) {
kfree(path_components);
......
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