From: Alan T. DeKok Date: Sun, 9 Mar 2025 14:05:17 +0000 (-0400) Subject: it helps to copy TMPL_TYPE_DATA, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=049723bf2f1a95d3d6187587515140e4352282c5;p=thirdparty%2Ffreeradius-server.git it helps to copy TMPL_TYPE_DATA, too and update the code so that all tmpl types are accounted for, OR if there's one missing, we hit an assert --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 0dd5be4635..097ee7d0d6 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -3633,12 +3633,13 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in) /* * Copy attribute references */ - if (tmpl_contains_attr(vpt) && unlikely(tmpl_attr_copy(vpt, in) < 0)) goto error; + else if (tmpl_contains_attr(vpt)) { + if (unlikely(tmpl_attr_copy(vpt, in) < 0)) goto error; /* * Copy flags for all regex flavours (and possibly recompile the regex) */ - if (tmpl_contains_regex(vpt)) { + } else if (tmpl_contains_regex(vpt)) { vpt->data.reg_flags = in->data.reg_flags; /* @@ -3655,7 +3656,6 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in) if (unlikely(tmpl_regex_compile(vpt, vpt->data.reg.subcaptures) < 0)) goto error; return vpt; } - } /* * Copy the xlat component. @@ -3664,10 +3664,16 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in) * * We add an assertion here because nothing allocates the head, and we need it. */ - if (tmpl_contains_xlat(vpt)) { + } else 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; + + } else if (tmpl_is_data(vpt)) { + if (unlikely(fr_value_box_copy(vpt, &vpt->data.literal, &in->data.literal) < 0)) goto error; + + } else { + fr_assert(0); /* copy of this type is unimplemented */ } TMPL_VERIFY(vpt);