chiark / gitweb /
sd-bus: fix invalid stack access on test-bus-marshal
[elogind.git] / src / libelogind / sd-bus / bus-objects.c
index 2eaa7de30628945b871d4383429a3081ee8fd1d2..cbdf6552f981caab1f48c3091de9623073c8459a 100644 (file)
@@ -1164,6 +1164,10 @@ static int process_get_managed_objects(
         if (bus->nodes_modified)
                 return 0;
 
+        r = set_put_strdup(s, m->path);
+        if (r < 0)
+                return r;
+
         r = sd_bus_message_new_method_return(m, &reply);
         if (r < 0)
                 return r;
@@ -1412,7 +1416,7 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) {
                 e = strrchr(path, '/');
                 assert(e);
 
-                p = strndupa(path, MAX(1, path - e));
+                p = strndupa(path, MAX(1, e - path));
 
                 parent = bus_node_allocate(bus, p);
                 if (!parent)