Un-tagged attributes can *never* have tags
authorAlan T. DeKok <aland@freeradius.org>
Thu, 2 Oct 2014 21:24:51 +0000 (17:24 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 2 Oct 2014 21:25:12 +0000 (17:25 -0400)
src/main/tmpl.c
src/tests/unit/condition.txt

index d2d6aa2..0c909ef 100644 (file)
@@ -773,20 +773,17 @@ ssize_t tmpl_from_attr_substr(value_pair_tmpl_t *vpt, char const *name,
         *      The string MIGHT have a tag.
         */
        if (*p == ':') {
+               if (!attr.da->flags.has_tag) {
+                       fr_strerror_printf("Attribute '%s' cannot have a tag", attr.da->name);
+                       return -(p - name);
+               }
+
                num = strtol(p + 1, &q, 10);
                if ((num > 0x1f) || (num < 0)) {
                        fr_strerror_printf("Invalid tag value '%li' (should be between 0-31)", num);
                        return -((p + 1)- name);
                }
 
-               if (!attr.da->flags.has_tag) {
-                       if (num != TAG_NONE) {
-                               fr_strerror_printf("Attribute '%s' cannot have a tag", attr.da->name);
-                               return -(p - name);
-                       }
-                       num = TAG_ANY;
-               }
-
                attr.tag = num;
                p = q;
        }
index dc17845..b70f9c4 100644 (file)
@@ -552,11 +552,10 @@ condition &User-Name:10 == 'test'
 data ERROR offset 10 Attribute 'User-Name' cannot have a tag
 
 #
-#  Tag zero is technically allowed for non-tagged attributes
-#  but should be ignored.
+#  Tags are always wrong for attributes which aren't tagged.
 #
 condition &User-Name:0 == 'test'
-data &User-Name == 'test'
+data ERROR offset 10 Attribute 'User-Name' cannot have a tag
 
 #
 #  Bounds checks...