summaryrefslogtreecommitdiff
path: root/src/binfmt
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-23 16:27:46 +0200
committerLennart Poettering <lennart@poettering.net>2020-04-23 17:14:41 +0200
commitf3670df13e144c2f81bf6f9a0bea581e6d555bdd (patch)
treeb83859493c6f6e6320032cd79e3a83d2ffe09986 /src/binfmt
parent0282c0285a3e3c2e409305ce28555a6ad0489539 (diff)
downloadsystemd-f3670df13e144c2f81bf6f9a0bea581e6d555bdd.tar.gz
binfmt: modernize code a bit
Let's just copy out the bit of the string we need, and let's make sure we refuse rules called "status" and "register", since those are special files in binfmt_misc's file system.
Diffstat (limited to 'src/binfmt')
-rw-r--r--src/binfmt/binfmt.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 7ff844c78c..5e812e89a5 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -32,18 +32,17 @@ static int delete_rule(const char *rule) {
assert(rule);
assert(rule[0]);
- x = strdup(rule);
+ e = strchrnul(rule + 1, rule[0]);
+ x = strndup(rule + 1, e - rule - 1);
if (!x)
return log_oom();
- e = strchrnul(x+1, x[0]);
- *e = 0;
-
- if (!filename_is_valid(x + 1))
+ if (!filename_is_valid(x) ||
+ STR_IN_SET(x, "register", "status"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Rule file name '%s' is not valid, refusing.", x + 1);
+ "Rule file name '%s' is not valid, refusing.", x);
- fn = path_join("/proc/sys/fs/binfmt_misc", x+1);
+ fn = path_join("/proc/sys/fs/binfmt_misc", x);
if (!fn)
return log_oom();