diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-25 13:23:44 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-25 14:28:34 +0100 |
commit | 9f6dfd0624e44002e407a72acb0c15b7177e9a9f (patch) | |
tree | d93d9c8f1d1b8ccb5f9d344799a419c3182ce679 | |
parent | 6dfcc64bb5c67ec2e026715146c19acf93dab31a (diff) |
sd-bus: fix error handling when receiving invalid service name
Also, properly keep track of incoming additional service names.
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index a8adb9c565..27a59109ba 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -646,19 +646,27 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) { break; case KDBUS_ITEM_DST_NAME: - if (!service_name_is_valid(d->str)) - return -EBADMSG; + if (!service_name_is_valid(d->str)) { + r = -EBADMSG; + goto fail; + } destination = d->str; break; case KDBUS_ITEM_OWNED_NAME: - if (!service_name_is_valid(d->name.name)) - return -EBADMSG; - - r = strv_extend(&m->creds.well_known_names, d->name.name); - if (r < 0) + if (!service_name_is_valid(d->name.name)) { + r = -EBADMSG; goto fail; + } + + if (bus->creds_mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) { + r = strv_extend(&m->creds.well_known_names, d->name.name); + if (r < 0) + goto fail; + + m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES; + } break; case KDBUS_ITEM_CONN_DESCRIPTION: |