From: Alejandro Colomar Date: Sun, 24 Aug 2025 07:29:33 +0000 (+0200) Subject: lib/subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID X-Git-Tag: 4.19.0-rc1~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02e930892590efd4023586696d05ce7ce2838e0f;p=thirdparty%2Fshadow.git 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 --- 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;