chiark / gitweb /
sd-bus: fix error handling when receiving invalid service name
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Nov 2014 12:23:44 +0000 (13:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Nov 2014 13:28:34 +0000 (14:28 +0100)
Also, properly keep track of incoming additional service names.

src/libsystemd/sd-bus/bus-kernel.c

index a8adb9c..27a5910 100644 (file)
@@ -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: