]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix crash on invalid attribute
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Thu, 27 Feb 2020 12:38:50 +0000 (12:38 +0000)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Thu, 27 Feb 2020 12:38:50 +0000 (12:38 +0000)
src/lib/server/xlat_builtin.c
src/tests/keywords/xlat-attr-tag

index 446967771ccb60b08f464572d6aa750565722e5d..2bba80a4baba6bd7124e98628c2c9765da330c51 100644 (file)
@@ -160,7 +160,7 @@ int xlat_fmt_to_cursor(TALLOC_CTX *ctx, fr_cursor_t **out,
                                &(vp_tmpl_rules_t){
                                        .dict_def = request->dict,
                                        .prefix = VP_ATTR_REF_PREFIX_AUTO
-                               }) < 0) {
+                               }) <= 0) {
                RPEDEBUG("Failed parsing attribute reference");
                return -1;
        }
index 18a63608ffd27e4469be3ab72b19df506647a7f7..6532ff716197530690119f3fe2bbb444ad191ac4 100644 (file)
@@ -46,6 +46,36 @@ if ("%{tag:control:Cleartext-Password[0]}" != '') {
        test_fail
 }
 
+# There should be no failures so far
+if (&Module-Failure-Message) {
+       test_fail
+}
+
+# Test invalid attributes
+if ("%{tag:foo}" != "") {
+       test_fail
+}
+
+if (&Module-Failure-Message != "Unknown attribute 'foo'") {
+       test_fail
+}
+
+update request {
+       &Module-Failure-Message !* ANY
+}
+
+if ("%{tag:%{control:Cleartext-Password}}" != "") {
+       test_fail
+}
+
+if (&Module-Failure-Message != "Unknown attribute 'hello'") {
+       test_fail
+}
+
+update request {
+       &Module-Failure-Message !* ANY
+}
+
 # Check that access attributes by tag works first
 if ("%{Tunnel-Server-Endpoint:2}" != '192.0.3.1') {
        test_fail