summaryrefslogtreecommitdiffstats
path: root/src/busctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-03-01 14:42:34 +0100
committerLennart Poettering <lennart@poettering.net>2024-03-01 22:24:01 +0100
commit5f76155e65ac21aca1ccbe945f1bfdd7feeb270b (patch)
tree05b79afb4dea6039e1a89891f584bb4aa6f84e13 /src/busctl
parentvmspawn: actually pass UUID down to qemu (diff)
downloadsystemd-5f76155e65ac21aca1ccbe945f1bfdd7feeb270b.tar.xz
systemd-5f76155e65ac21aca1ccbe945f1bfdd7feeb270b.zip
busctl: don't hit an assert if we call invalid bus method names
We should validate this explicitly and generate a clear error string, rather then hit an assert() later in the code.
Diffstat (limited to 'src/busctl')
-rw-r--r--src/busctl/busctl.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index 6314ff8d1d..9c750fcd53 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -2021,6 +2021,15 @@ static int call(int argc, char **argv, void *userdata) {
if (r < 0)
return r;
+ if (!service_name_is_valid(argv[1]))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid service name: %s", argv[1]);
+ if (!object_path_is_valid(argv[2]))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid object path: %s", argv[2]);
+ if (!interface_name_is_valid(argv[3]))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid interface name: %s", argv[3]);
+ if (!member_name_is_valid(argv[4]))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid member name: %s", argv[4]);
+
r = sd_bus_message_new_method_call(bus, &m, argv[1], argv[2], argv[3], argv[4]);
if (r < 0)
return bus_log_create_error(r);