]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check for TAG_VALID instead of !=TAG_ANY
authorAlan T. DeKok <aland@freeradius.org>
Mon, 8 Jan 2018 16:05:14 +0000 (11:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 8 Jan 2018 16:06:10 +0000 (11:06 -0500)
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

src/main/tmpl.c
src/main/xlat_tokenize.c
src/tests/unit/xlat.txt

index 65cd7022732eb3b81f52b4d12a9fdcb2928bb202..67afd5ad647b3cd1c8f87b241b3b23f32432421c 100644 (file)
@@ -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);
                        }
index b42b47ed3e0d462f774afa69239a402ac157edb9..4c6e878e7d4d91040a4e3cf7a31e00734d2bdb51 100644 (file)
@@ -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);
                        }
 
index 2d617002e213808c2717517bec2581d4dd703f93..720a3a7475dc25daccc27df0da4e5cfb3fb33649 100644 (file)
@@ -1,3 +1,7 @@
+xlat %{Tunnel-Password}
+data %{Tunnel-Password}
+
+
 #
 #  Tests for xlat expansion
 #