]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Use parse_syscall_archs() in bus_exec_context_set_transient_property()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 13:48:13 +0000 (15:48 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Apr 2025 01:15:19 +0000 (10:15 +0900)
src/core/dbus-execute.c
src/shared/seccomp-util.c

index 3953e775ecd28c2940f1b2521133f6437d2abc72..2a257f126033d901b343d37136c491f2b84d5ab7 100644 (file)
@@ -2771,18 +2771,11 @@ int bus_exec_context_set_transient_property(
 
                         if (strv_isempty(l))
                                 c->syscall_archs = set_free(c->syscall_archs);
-                        else
-                                STRV_FOREACH(s, l) {
-                                        uint32_t a;
-
-                                        r = seccomp_arch_from_string(*s, &a);
-                                        if (r < 0)
-                                                return r;
-
-                                        r = set_ensure_put(&c->syscall_archs, NULL, UINT32_TO_PTR(a + 1));
-                                        if (r < 0)
-                                                return r;
-                                }
+                        else {
+                                r = parse_syscall_archs(l, &c->syscall_archs);
+                                if (r < 0)
+                                        return r;
+                        }
 
                         joined = strv_join(l, " ");
                         if (!joined)
index 5234f11ea0e1a851c91fabff1f77aeec886e50e2..7f6d6103b8213b3b746ef43aac2177df6c542aa0 100644 (file)
@@ -2019,12 +2019,11 @@ int seccomp_restrict_archs(Set *archs) {
         return 0;
 }
 
-int parse_syscall_archs(char **l, Set **ret_archs) {
-        _cleanup_set_free_ Set *archs = NULL;
+int parse_syscall_archs(char **l, Set **archs) {
         int r;
 
         assert(l);
-        assert(ret_archs);
+        assert(archs);
 
         STRV_FOREACH(s, l) {
                 uint32_t a;
@@ -2033,12 +2032,11 @@ int parse_syscall_archs(char **l, Set **ret_archs) {
                 if (r < 0)
                         return -EINVAL;
 
-                r = set_ensure_put(&archs, NULL, UINT32_TO_PTR(a + 1));
+                r = set_ensure_put(archs, NULL, UINT32_TO_PTR(a + 1));
                 if (r < 0)
                         return -ENOMEM;
         }
 
-        *ret_archs = TAKE_PTR(archs);
         return 0;
 }