(cherry picked from commit f519a19bcd5afe674a9b8fc462cd77d8bad403c1)
[baruch: backport to v240]
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+[Adam: Update for v241]
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
-Upstream status: commit f519a19bcd5
-
src/libsystemd/sd-bus/bus-objects.c | 68 +++++++++++++++++++++++------
1 file changed, 54 insertions(+), 14 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
-index d0538104ae25..54b977418e03 100644
+index 58329f3fe78..54b977418e0 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -1133,7 +1133,8 @@ static int object_manager_serialize_path_and_fallbacks(
return 0;
/* Second, add fallback vtables registered for any of the prefixes */
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
+ pl = strlen(path);
+ assert(pl <= BUS_PATH_SIZE_MAX);
+ prefix = new(char, pl + 1);
+ if (!prefix)
+ return -ENOMEM;
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
OBJECT_PATH_FOREACH_PREFIX(prefix, path) {
n = hashmap_get(bus->nodes, prefix);
if (n)
if (bus->nodes_modified)
continue;
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
OBJECT_PATH_FOREACH_PREFIX(prefix, path) {
r = emit_properties_changed_on_interface(bus, prefix, path, interface, true, &found_interface, names);
if (r != 0)
if (bus->nodes_modified)
return 0;
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
+ pl = strlen(path);
+ assert(pl <= BUS_PATH_SIZE_MAX);
+ prefix = new(char, pl + 1);
if (bus->nodes_modified)
return 0;
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
+ pl = strlen(path);
+ assert(pl <= BUS_PATH_SIZE_MAX);
+ prefix = new(char, pl + 1);
if (bus->nodes_modified)
return 0;
-- prefix = alloca(strlen(path) + 1);
+- prefix = newa(char, strlen(path) + 1);
+ pl = strlen(path);
+ assert(pl <= BUS_PATH_SIZE_MAX);
+ prefix = new(char, pl + 1);