]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID
authorAlejandro Colomar <alx@kernel.org>
Sun, 24 Aug 2025 07:29:33 +0000 (09:29 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Thu, 28 Aug 2025 18:27:52 +0000 (20:27 +0200)
Fixes: 3ec32f9975f2 (2022-07-20; "subordinateio: also compare the owner ID")
Closes: <https://github.com/shadow-maint/shadow/issues/1339>
Link: <https://github.com/cri-o/cri-o/issues/9416>
Reported-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/subordinateio.c

index 058a097058d68525e8fe826455e2158c8a2fddd8..dc585f78b56efd8a5ff008467c2dedd0a52cbc97 100644 (file)
@@ -885,17 +885,9 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r
 
        commonio_rewind(db);
        while (NULL != (range = commonio_next(db))) {
-               if (streq(range->owner, owner)) {
-                       if (!append_range(&ranges, range, count++)) {
-                               free(ranges);
-                               ranges = NULL;
-                               count = -1;
-                               goto out;
-                       }
-               }
-
-               // Let's also compare with the ID
-               if (have_owner_id == true && streq(range->owner, id)) {
+               if (   streq(range->owner, owner)
+                   || (have_owner_id && streq(range->owner, id)))
+               {
                        if (!append_range(&ranges, range, count++)) {
                                free(ranges);
                                ranges = NULL;