Skip to content

Commit 12c948b

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) (cherry picked from commit 71efbe6)
1 parent a019470 commit 12c948b

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
@@ -2741,7 +2741,7 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
27412741
flags = unit_file_bools_to_flags(runtime, force);
27422742

27432743
dep = unit_dependency_from_string(type);
2744-
if (dep < 0)
2744+
if (dep < 0 || !IN_SET(dep, UNIT_WANTS, UNIT_REQUIRES))
27452745
return -EINVAL;
27462746

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

0 commit comments

Comments
 (0)