]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Descend into unresolved xlat functions too
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 1 Dec 2021 14:29:12 +0000 (08:29 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 1 Dec 2021 20:06:30 +0000 (14:06 -0600)
This fixes a bug where xlat functions calls that were children of an unresolved xlat function call were never instantiated, even if that call was later resolved.

It presented with crashes when using %{expr:} as that function is registered by a module and is initially unresolved.

src/lib/unlang/xlat_eval.c

index 7d40cf4848cd2436dd0fa65227294e00c450aa10..7ad123ea2f38e276a3c5f8b30e642f3127be05ef 100644 (file)
@@ -2127,6 +2127,21 @@ int xlat_eval_walk(xlat_exp_t *exp, xlat_walker_t walker, xlat_type_t type, void
                        }
                        break;
 
+               case XLAT_FUNC_UNRESOLVED:
+                       if (!type || (type & XLAT_FUNC_UNRESOLVED)) {
+                               ret = walker(node, uctx);
+                               if (ret < 0) return ret;
+                       }
+
+                       /*
+                        *      Now evaluate the function's arguments
+                        */
+                       if (node->child) {
+                               ret = xlat_eval_walk(node->child, walker, type, uctx);
+                               if (ret < 0) return ret;
+                       }
+                       break;
+
                case XLAT_ALTERNATE:
                        if (!type || (type & XLAT_ALTERNATE)) {
                                ret = walker(node, uctx);