Skip to content

Commit 71efbe6

Browse files
committed
core: fix assert when AddDependencyUnitFiles is called with invalid parameter
unit_file_add_dependency() asserts, so check before calling it that the type is expected, or return EINVAL to the caller. root@localhost:~# busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager AddDependencyUnitFiles "asssbb" 0 uwhatm8 After 1 1 Broadcast message from systemd-journald@localhost (Mon 2025-01-06 18:12:14 UTC): systemd[1]: Caught <ABRT>, from our own process. Fixes systemd/systemd#35882 (cherry picked from commit d87dc74) (cherry picked from commit b679220) (cherry picked from commit c65056e) (cherry picked from commit 4d47117)
1 parent af8cb09 commit 71efbe6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/core/dbus-manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,7 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
28202820
flags = unit_file_bools_to_flags(runtime, force);
28212821

28222822
dep = unit_dependency_from_string(type);
2823-
if (dep < 0)
2823+
if (dep < 0 || !IN_SET(dep, UNIT_WANTS, UNIT_REQUIRES))
28242824
return -EINVAL;
28252825

28262826
r = unit_file_add_dependency(m->runtime_scope, flags, NULL, l, target, dep, &changes, &n_changes);

0 commit comments

Comments
 (0)