From: Tobias Stoeckmann Date: Sat, 24 May 2025 10:29:36 +0000 (+0200) Subject: archive_match: Use correct data type for iterator X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bef52da6221b7f272fa4ba2294a8bf5f827543c0;p=thirdparty%2Flibarchive.git 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 --- 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)