]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
be more careful about parsing %{1}
authorAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:26:11 +0000 (10:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:26:11 +0000 (10:26 -0400)
src/lib/unlang/xlat_tokenize.c

index 996330707140be2cdc7193b7815dd58f6f11e91b..e06ad3f5bd9dd32d8e45ecb5e2523dd1de391c94 100644 (file)
@@ -956,17 +956,23 @@ int xlat_tokenize_expansion(xlat_exp_head_t *head, fr_sbuff_t *in,
        }
 
 #ifdef HAVE_REGEX
+       fr_sbuff_marker(&s_m, in);
+       len = fr_sbuff_adv_past_allowed(in, SIZE_MAX, sbuff_char_class_uint, NULL);
+
        /*
         *      Handle regex's %{<num>} specially.  But '3GPP-Foo' is an attribute.  :(
         */
-       if (fr_sbuff_is_digit(in)) {
+       if (len && fr_sbuff_is_char(in, '}')) {
                int ret;
 
+               fr_sbuff_set(in, &s_m);         /* backtrack */
                ret = xlat_tokenize_regex(head, in);
                if (ret <= 0) return ret;
 
                /* ret==1 means "nope, it's an attribute" */
        }
+       fr_sbuff_set(in, &s_m);         /* backtrack */
+
 #endif /* HAVE_REGEX */
 
        /*