]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: limit the number of units that can be requested over ListUnitsByNames 41864/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 29 Apr 2026 10:02:32 +0000 (12:02 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 29 Apr 2026 10:58:58 +0000 (12:58 +0200)
src/core/dbus-manager.c

index 1bc73e7b434c91a3d1af8e19296216c419c7e1a1..6579708df0117b8bfa640039cf0cf07d0368e8cc 100644 (file)
@@ -971,6 +971,10 @@ static int method_list_units_by_names(sd_bus_message *message, void *userdata, s
         if (r < 0)
                 return r;
 
+        if (strv_length(units) > MAX(hashmap_size(m->units), (unsigned) MANAGER_MAX_NAMES / 2))
+                return sd_bus_error_set(reterr_error, SD_BUS_ERROR_LIMITS_EXCEEDED,
+                                        "Too many unit names requested.");
+
         r = sd_bus_message_new_method_return(message, &reply);
         if (r < 0)
                 return r;