From 2bbcf781263f179479257c6d09c9aee5ff32a19b Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 28 Sep 2025 16:26:03 +0200 Subject: [PATCH 1/2] gpattern: Set max_length to G_MAXSIZE for wildcard If a wildcard is seen, se max_length to G_MAXSIZE, otherwise strings longer than G_UINTMAX would not match. --- glib/gpattern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gpattern.c b/glib/gpattern.c index b12afdbb7..7ed7ed311 100644 --- a/glib/gpattern.c +++ b/glib/gpattern.c @@ -361,7 +361,7 @@ g_pattern_spec_new (const gchar *pattern) seen_wildcard = hw_pos_set; more_wildcards = seen_wildcard && hw_pos != tw_pos; if (seen_wildcard) - pspec->max_length = G_MAXUINT; + pspec->max_length = G_MAXSIZE; /* special case sole head/tail wildcard or exact matches */ if (!seen_joker && !more_wildcards) From b9eee47954a2cd2183fe3b667e5882dd6b6d3def Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 28 Sep 2025 16:32:26 +0200 Subject: [PATCH 2/2] gpattern: Support arbitrary amount of jokers If a pattern with more than 4 GB question marks is parsed, then the counter would overflow. Turn to a size_t for arbitrary amount on 64 bit systems. --- glib/gpattern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gpattern.c b/glib/gpattern.c index 7ed7ed311..7d85f05d1 100644 --- a/glib/gpattern.c +++ b/glib/gpattern.c @@ -292,7 +292,7 @@ g_pattern_spec_new (const gchar *pattern) size_t hw_pos = 0, tw_pos = 0, hj_pos = 0, tj_pos = 0; gboolean hw_pos_set = FALSE, hj_pos_set = FALSE; gboolean follows_wildcard = FALSE; - guint pending_jokers = 0; + size_t pending_jokers = 0; const gchar *s; gchar *d; size_t i;