chiark / gitweb /
bus: do not add empty strings, size should be 0
authorKay Sievers <kay@vrfy.org>
Thu, 19 Dec 2013 05:55:44 +0000 (06:55 +0100)
committerKay Sievers <kay@vrfy.org>
Thu, 19 Dec 2013 05:56:53 +0000 (06:56 +0100)
src/libsystemd-bus/bus-control.c

index b8f6360..5540d85 100644 (file)
@@ -775,12 +775,12 @@ static int add_name_change_match(sd_bus *bus,
                  * name, then add KDBUS_MATCH_NAME_{ADD,REMOVE,CHANGE}
                  * matches for it */
 
-                l = name ? strlen(name) : 0;
+                l = name ? strlen(name) + 1 : 0;
 
                 sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) +
                             offsetof(struct kdbus_item, name_change) +
                             offsetof(struct kdbus_notify_name_change, name) +
-                            l+1);
+                            l);
 
                 m = alloca0(sz);
                 m->size = sz;
@@ -791,7 +791,7 @@ static int add_name_change_match(sd_bus *bus,
                 item->size =
                         offsetof(struct kdbus_item, name_change) +
                         offsetof(struct kdbus_notify_name_change, name) +
-                        l+1;
+                        l;
 
                 item->name_change.old.id = old_owner_id;
                 item->name_change.new.id = new_owner_id;