summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-22 02:20:21 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-22 02:20:21 +0100
commitdafb75912a65e72c3989143f79367a652323a69f (patch)
tree08f233b5351706f7a8b85f88a843148de4415177 /src/libsystemd-bus/sd-bus.c
parent813a4f93750be40eff13f127dfef8364642a13bc (diff)
bus: validate the hello response properly
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r--src/libsystemd-bus/sd-bus.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 6a6d43fac0..4bfbd4c651 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -104,16 +104,19 @@ static int hello_callback(sd_bus *bus, int error, sd_bus_message *reply, void *u
assert(reply);
- bus->state = BUS_RUNNING;
-
r = sd_bus_message_read(reply, "s", &s);
if (r < 0)
return r;
+ if (!service_name_is_valid(s) || s[0] != ':')
+ return -EBADMSG;
+
bus->unique_name = strdup(s);
if (!bus->unique_name)
return -ENOMEM;
+ bus->state = BUS_RUNNING;
+
return 1;
}