Skip to content

Commit 049723b

Browse files
committed
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
1 parent 0768aa8 commit 049723b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/server/tmpl_tokenize.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,12 +3633,13 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
36333633
/*
36343634
* Copy attribute references
36353635
*/
3636-
if (tmpl_contains_attr(vpt) && unlikely(tmpl_attr_copy(vpt, in) < 0)) goto error;
3636+
else if (tmpl_contains_attr(vpt)) {
3637+
if (unlikely(tmpl_attr_copy(vpt, in) < 0)) goto error;
36373638

36383639
/*
36393640
* Copy flags for all regex flavours (and possibly recompile the regex)
36403641
*/
3641-
if (tmpl_contains_regex(vpt)) {
3642+
} else if (tmpl_contains_regex(vpt)) {
36423643
vpt->data.reg_flags = in->data.reg_flags;
36433644

36443645
/*
@@ -3655,7 +3656,6 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
36553656
if (unlikely(tmpl_regex_compile(vpt, vpt->data.reg.subcaptures) < 0)) goto error;
36563657
return vpt;
36573658
}
3658-
}
36593659

36603660
/*
36613661
* Copy the xlat component.
@@ -3664,10 +3664,16 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
36643664
*
36653665
* We add an assertion here because nothing allocates the head, and we need it.
36663666
*/
3667-
if (tmpl_contains_xlat(vpt)) {
3667+
} else if (tmpl_contains_xlat(vpt)) {
36683668
fr_assert(vpt->data.xlat.ex != NULL);
36693669

36703670
if (unlikely(xlat_copy(vpt, vpt->data.xlat.ex, in->data.xlat.ex) < 0)) goto error;
3671+
3672+
} else if (tmpl_is_data(vpt)) {
3673+
if (unlikely(fr_value_box_copy(vpt, &vpt->data.literal, &in->data.literal) < 0)) goto error;
3674+
3675+
} else {
3676+
fr_assert(0); /* copy of this type is unimplemented */
36713677
}
36723678

36733679
TMPL_VERIFY(vpt);

0 commit comments

Comments
 (0)