bus: validate the hello response properly

This commit is contained in:
Lennart Poettering 2013-03-22 02:20:21 +01:00
parent 813a4f9375
commit dafb75912a
1 changed files with 5 additions and 2 deletions

View 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;
}