From: Alan T. DeKok Date: Mon, 8 Jan 2018 16:05:14 +0000 (-0500) Subject: check for TAG_VALID instead of !=TAG_ANY X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1316669b2e3b980f64a59b60899ea2c43bfcf4e;p=thirdparty%2Ffreeradius-server.git check for TAG_VALID instead of !=TAG_ANY looking for valid ranges is smarter than checking for different from a magic value, because there may be LOTS of magic values, and LOTS of invalid values --- diff --git a/src/main/tmpl.c b/src/main/tmpl.c index 65cd7022732..67afd5ad647 100644 --- a/src/main/tmpl.c +++ b/src/main/tmpl.c @@ -2416,7 +2416,7 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt) fr_dict_attr_t const *da; if (!vpt->tmpl_da->flags.has_tag && - (vpt->tmpl_tag != TAG_ANY)) { + TAG_VALID_ZERO(vpt->tmpl_tag)) { FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR " "da is marked as not having a tag, but the template has a tag", file, line); @@ -2425,9 +2425,9 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt) #if 0 if (vpt->tmpl_da->flags.has_tag && - (vpt->tmpl_tag == TAG_ANY)) { + !TAG_VALID_ZERO(vpt->tmpl_tag)) { FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR " - "da is marked as having a tag, but the template has no tag", + "da is marked as not having a tag, but the template has an invalid tag", file, line); if (!fr_cond_assert(0)) fr_exit_now(1); } diff --git a/src/main/xlat_tokenize.c b/src/main/xlat_tokenize.c index b42b47ed3e0..4c6e878e7d4 100644 --- a/src/main/xlat_tokenize.c +++ b/src/main/xlat_tokenize.c @@ -653,6 +653,9 @@ size_t xlat_snprint(char *buffer, size_t bufsize, xlat_exp_t const *node) *(p++) = '%'; *(p++) = '{'; + /* + * @todo - just call tmpl_snprint() ?? + */ if (node->attr->tmpl_request != REQUEST_CURRENT) { strlcpy(p, fr_int2str(request_refs, node->attr->tmpl_request, "??"), end - p); p += strlen(p); @@ -669,9 +672,9 @@ size_t xlat_snprint(char *buffer, size_t bufsize, xlat_exp_t const *node) strlcpy(p, node->attr->tmpl_da->name, end - p); p += strlen(p); - if (node->attr->tmpl_tag != TAG_ANY) { + if (TAG_VALID(node->attr->tmpl_tag)) { *(p++) = ':'; - snprintf(p, end - p, "%u", node->attr->tmpl_tag); + snprintf(p, end - p, "%d", node->attr->tmpl_tag); p += strlen(p); } diff --git a/src/tests/unit/xlat.txt b/src/tests/unit/xlat.txt index 2d617002e21..720a3a7475d 100644 --- a/src/tests/unit/xlat.txt +++ b/src/tests/unit/xlat.txt @@ -1,3 +1,7 @@ +xlat %{Tunnel-Password} +data %{Tunnel-Password} + + # # Tests for xlat expansion #