]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor fixes
authorAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:43:30 +0000 (10:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:43:30 +0000 (10:43 -0400)
if we have a cast, then we don't have an enumv, and we can't
parse the data as being an enum name.

if we have a subexpression, (...), then we don't do math on
enum names, so remove the enum there, too.

Pass the resulting rules recursively to the parser

src/lib/unlang/xlat_expr.c

index 63dabfef49978e3ce4752717e05ab4c9d68ca555..0eb4012dcb9385f89301f7a9e4357f24ce1108e3 100644 (file)
@@ -2156,7 +2156,10 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
         *      We may end up removing the cast later, if for example the tmpl is an attribute whose data type
         *      matches the cast.
         */
-       if (cast_type != FR_TYPE_NULL) our_t_rules.cast = cast_type;
+       if (cast_type != FR_TYPE_NULL) {
+               our_t_rules.cast = cast_type;
+               our_t_rules.enumv = NULL;
+       }
 
        /*
         *      If we still have '(', then recurse for other expressions
@@ -2169,11 +2172,14 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
         *      value when we get the output of the expression.
         */
        if (fr_sbuff_next_if_char(&our_in, '(')) {
+               our_t_rules.cast = FR_TYPE_NULL;
+               our_t_rules.enumv = NULL;
+
                /*
                 *      No input rules means "ignore external terminal sequences, as we're expecting a ')' as
                 *      our terminal sequence.
                 */
-               if (tokenize_expression(head, &node, &our_in, bracket_rules, t_rules, T_INVALID, bracket_rules, NULL, cond) < 0) {
+               if (tokenize_expression(head, &node, &our_in, bracket_rules, &our_t_rules, T_INVALID, bracket_rules, NULL, cond) < 0) {
                        FR_SBUFF_ERROR_RETURN(&our_in);
                }