From: Arran Cudbard-Bell Date: Sat, 16 May 2015 15:53:28 +0000 (-0400) Subject: Print meaningful errors for unknown attrs with tags X-Git-Tag: release_3_0_9~353 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cd03749545c3bb98d7a791cee0312ce1b5effe2;p=thirdparty%2Ffreeradius-server.git Print meaningful errors for unknown attrs with tags --- diff --git a/src/main/tmpl.c b/src/main/tmpl.c index e79faf73ef0..6b9a1ab36c6 100644 --- a/src/main/tmpl.c +++ b/src/main/tmpl.c @@ -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, "")); 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, "")); TALLOC_FREE(vpt); return -slen; } diff --git a/src/tests/unit/condition.txt b/src/tests/unit/condition.txt index 6bc35573af9..f7d055c21fb 100644 --- a/src/tests/unit/condition.txt +++ b/src/tests/unit/condition.txt @@ -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 ¬-a-list:User-Name == ¬-a-list:User-Name data ERROR offset 1 Invalid list qualifier