From 02e930892590efd4023586696d05ce7ce2838e0f Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 24 Aug 2025 09:29:33 +0200 Subject: [PATCH] lib/subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID Fixes: 3ec32f9975f2 (2022-07-20; "subordinateio: also compare the owner ID") Closes: Link: Reported-by: Anatolii Bazko Signed-off-by: Alejandro Colomar --- lib/subordinateio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 058a09705..dc585f78b 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -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; -- 2.47.3