From: Matthew Newton Date: Thu, 27 Feb 2020 12:38:50 +0000 (+0000) Subject: fix crash on invalid attribute X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12d0fb64cd7bb289dbb7c43107c9263cd3225d23;p=thirdparty%2Ffreeradius-server.git fix crash on invalid attribute --- diff --git a/src/lib/server/xlat_builtin.c b/src/lib/server/xlat_builtin.c index 446967771cc..2bba80a4bab 100644 --- a/src/lib/server/xlat_builtin.c +++ b/src/lib/server/xlat_builtin.c @@ -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; } diff --git a/src/tests/keywords/xlat-attr-tag b/src/tests/keywords/xlat-attr-tag index 18a63608ffd..6532ff71619 100644 --- a/src/tests/keywords/xlat-attr-tag +++ b/src/tests/keywords/xlat-attr-tag @@ -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