From bef52da6221b7f272fa4ba2294a8bf5f827543c0 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sat, 24 May 2025 12:29:36 +0200 Subject: [PATCH] archive_match: Use correct data type for iterator Iterating over a size_t with unsigned could lead to an endless loop while adding uid/gid to a list which already counts 4 billion entries. I doubt that this can ever happen, given that the routines become very slow with insertions, but better be safe than sorry. Signed-off-by: Tobias Stoeckmann --- libarchive/archive_match.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c index 67fc16fe9..2215f9a0c 100644 --- a/libarchive/archive_match.c +++ b/libarchive/archive_match.c @@ -1680,7 +1680,7 @@ archive_match_owner_excluded(struct archive *_a, static int add_owner_id(struct archive_match *a, struct id_array *ids, int64_t id) { - unsigned i; + size_t i; if (ids->count + 1 >= ids->size) { void *p; @@ -1717,10 +1717,10 @@ add_owner_id(struct archive_match *a, struct id_array *ids, int64_t id) static int match_owner_id(struct id_array *ids, int64_t id) { - unsigned b, m, t; + size_t b, m, t; t = 0; - b = (unsigned)ids->count; + b = ids->count; while (t < b) { m = (t + b)>>1; if (ids->ids[m] == id) -- 2.47.2