chiark / gitweb /
bus: when parsing enforce maximum container depth
[elogind.git] / src / libsystemd-bus / sd-bus.c
index 6a6d43fac0a03dd01eac4f38faf6527345601804..9408806a4e85bfa1df00f35b1a5cb099fa4b3e3d 100644 (file)
@@ -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;
 }
 
@@ -1032,7 +1035,7 @@ static int dispatch_wqueue(sd_bus *bus) {
 }
 
 static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
-        sd_bus_message *z;
+        sd_bus_message *z = NULL;
         int r, ret = 0;
 
         assert(bus);