]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
do compile-time checks for unresolved attributes
authorAlan T. DeKok <aland@freeradius.org>
Tue, 19 Jan 2021 14:49:06 +0000 (09:49 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 19 Jan 2021 15:39:16 +0000 (10:39 -0500)
src/lib/unlang/xlat_tokenize.c
src/tests/keywords/xlat-unknown

index 3b1d4e2b5dbb17d040d7b6480e48ad324ca32986..7568155366d5ed2fbaf5dc30097502d4f756c324 100644 (file)
@@ -635,6 +635,7 @@ static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **head, xl
 
                node->flags.needs_resolving = tmpl_is_attr_unresolved(vpt);
                node->attr = vpt;
+               node->flags.needs_resolving = tmpl_is_attr_unresolved(vpt);
        }
 
        if (!fr_sbuff_next_if_char(in, '}')) {
@@ -1653,6 +1654,7 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved)
                                 *      FIXME - Produce proper error with marker
                                 */
                                if (!allow_unresolved) {
+                               error_unresolved:
                                        fr_strerror_printf_push("Failed resolving attribute in expansion %%{%s}",
                                                                node->fmt);
                                        return -1;
@@ -1674,6 +1676,10 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved)
                }
                        break;
 
+               case XLAT_ATTRIBUTE:
+                       if (!allow_unresolved) goto error_unresolved;
+                       break;
+
                default:
                        fr_assert(0);   /* Should not have been marked as unresolved */
                        return -1;
index 921b447101b56b0803ba1b4aecf758155554d0eb..13ac85c1dbd66a2db5b4975a30c209e4618f6553 100644 (file)
@@ -10,9 +10,10 @@ update reply {
 #  reference here should be to an unknown attribute,
 #  and the dereference should fail.
 #
-if ("%{reply.WiMAX.Capability.Release}" == "foo") {
+if ("%{reply.WiMAX.Capability.Release}" == "foo") { # ERROR
        test_fail
 }
 else {
-       success
-}
\ No newline at end of file
+       # if it isn't a parse error, then it's a run-time error,
+       test_fail
+}