From: Tobias Stoeckmann Date: Sat, 24 May 2025 10:28:08 +0000 (+0200) Subject: archive_match: Allow arbitrarily long match lists X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b763d872c62378c4bfe536f7f7d0313f680d579;p=thirdparty%2Flibarchive.git archive_match: Allow arbitrarily long match lists Turn unmatched_count into a size_t to support as many entries as possible on the machine. If more than INT_MAX entries are not matched, truncate the result of archive_match_path_unmatched_inclusions for external callers. Signed-off-by: Tobias Stoeckmann --- diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c index cefdf458d..67fc16fe9 100644 --- a/libarchive/archive_match.c +++ b/libarchive/archive_match.c @@ -35,6 +35,9 @@ #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_LIMITS_H +#include +#endif #include "archive.h" #include "archive_private.h" @@ -53,7 +56,7 @@ struct match { struct match_list { struct match *first; struct match **last; - int unmatched_count; + size_t unmatched_count; struct match *unmatched_next; int unmatched_eof; }; @@ -508,7 +511,9 @@ archive_match_path_unmatched_inclusions(struct archive *_a) ARCHIVE_STATE_NEW, "archive_match_unmatched_inclusions"); a = (struct archive_match *)_a; - return (a->inclusions.unmatched_count); + if (a->inclusions.unmatched_count > (size_t)INT_MAX) + return INT_MAX; + return (int)(a->inclusions.unmatched_count); } int