chiark / gitweb /
bus: validate the hello response properly
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2013 01:20:21 +0000 (02:20 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2013 01:20:21 +0000 (02:20 +0100)
src/libsystemd-bus/sd-bus.c

index 6a6d43f..4bfbd4c 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;
 }