Skip to content

Commit 8b763d8

Browse files
committed
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 <tobias@stoeckmann.org>
1 parent 51e66d3 commit 8b763d8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

libarchive/archive_match.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#ifdef HAVE_STRING_H
3636
#include <string.h>
3737
#endif
38+
#ifdef HAVE_LIMITS_H
39+
#include <limits.h>
40+
#endif
3841

3942
#include "archive.h"
4043
#include "archive_private.h"
@@ -53,7 +56,7 @@ struct match {
5356
struct match_list {
5457
struct match *first;
5558
struct match **last;
56-
int unmatched_count;
59+
size_t unmatched_count;
5760
struct match *unmatched_next;
5861
int unmatched_eof;
5962
};
@@ -508,7 +511,9 @@ archive_match_path_unmatched_inclusions(struct archive *_a)
508511
ARCHIVE_STATE_NEW, "archive_match_unmatched_inclusions");
509512
a = (struct archive_match *)_a;
510513

511-
return (a->inclusions.unmatched_count);
514+
if (a->inclusions.unmatched_count > (size_t)INT_MAX)
515+
return INT_MAX;
516+
return (int)(a->inclusions.unmatched_count);
512517
}
513518

514519
int

0 commit comments

Comments
 (0)