]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
we can't in general copy xlats.
authorAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:25:26 +0000 (10:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 1 Oct 2023 14:25:26 +0000 (10:25 -0400)
because they need resolving.  And copying an xlat means that
the xlat does not appear in the instance tree

src/lib/server/tmpl_tokenize.c

index 1978ddaf483e8e5a4e3189218c4e52f851022125..6202f479c8161440981120566c7ee59e87d6b63e 100644 (file)
@@ -3379,9 +3379,17 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
        }
 
        /*
-        *      Copy the xlat component
+        *      Copy the xlat component.
+        *
+        *      @todo - in general we can't copy an xlat, as the instances need resolving!
+        *
+        *      We add an assertion here because nothing allocates the head, and we need it.
         */
-       if (tmpl_contains_xlat(vpt) && unlikely(xlat_copy(vpt, vpt->data.xlat.ex, in->data.xlat.ex) < 0)) goto error;
+       if (tmpl_contains_xlat(vpt)) {
+               fr_assert(vpt->data.xlat.ex != NULL);
+
+               if (unlikely(xlat_copy(vpt, vpt->data.xlat.ex, in->data.xlat.ex) < 0)) goto error;
+       }
 
        return vpt;
 }