]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print meaningful errors for unknown attrs with tags
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 May 2015 15:53:28 +0000 (11:53 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 May 2015 20:08:50 +0000 (16:08 -0400)
src/main/tmpl.c
src/tests/unit/condition.txt

index e79faf73ef0899319345b436f3e12151a65769b2..6b9a1ab36c60e7f73baa6d141767cc0b55558688 100644 (file)
@@ -778,7 +778,8 @@ ssize_t tmpl_from_attr_str(vp_tmpl_t *vpt, char const *name,
        slen = tmpl_from_attr_substr(vpt, name, request_def, list_def, allow_unknown, allow_undefined);
        if (slen <= 0) return slen;
        if (name[slen] != '\0') {
-               fr_strerror_printf("Unexpected text after attribute name");
+               /* This looks wrong, but it produces meaningful errors for unknown attrs with tags */
+               fr_strerror_printf("Unexpected text after %s", fr_int2str(tmpl_names, vpt->type, "<INVALID>"));
                return -slen;
        }
 
@@ -862,7 +863,8 @@ ssize_t tmpl_afrom_attr_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name,
                return slen;
        }
        if (name[slen] != '\0') {
-               fr_strerror_printf("Unexpected text after attribute name");
+               /* This looks wrong, but it produces meaningful errors for unknown attrs with tags */
+               fr_strerror_printf("Unexpected text after %s", fr_int2str(tmpl_names, vpt->type, "<INVALID>"));
                TALLOC_FREE(vpt);
                return -slen;
        }
index 6bc35573af90533ded65f7983f1c830e23fc2e37..f7d055c21fb5ba3ad9f2d15f7b378222bdb4016f 100644 (file)
@@ -592,14 +592,14 @@ condition request:Foo+Bar == request:Foo+Bar
 data true
 
 condition &request:Foo+Bar == 'request:Foo+Bar'
-data ERROR offset 12 Unexpected text after attribute name
+data ERROR offset 12 Unexpected text after unknown attr
 
 condition 'request:Foo+d' == &request:Foo+Bar
-data ERROR offset 31 Unexpected text after attribute name
+data ERROR offset 31 Unexpected text after unknown attr
 
 #  Attribute tags are not allowed for unknown attributes
 condition &request:FooBar:0 == &request:FooBar
-data ERROR offset 15 Unexpected text after attribute name
+data ERROR offset 15 Unexpected text after unknown attr
 
 condition &not-a-list:User-Name == &not-a-list:User-Name
 data ERROR offset 1 Invalid list qualifier