]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
do fast-path checks for errors
authorAlan T. DeKok <aland@freeradius.org>
Thu, 12 Aug 2021 14:41:02 +0000 (10:41 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 12 Aug 2021 14:41:02 +0000 (10:41 -0400)
the error message is the same, but the difference is do we error
out immediately, or later, after all of the rest of the dictionaries
have been loaded.

src/lib/util/dict_fixup.c

index 4ad3b97512166bb3402b2c86c2e5e4e9ced48035..e7e10001214d5db2967866d744e052d59814184f 100644 (file)
@@ -383,6 +383,20 @@ int dict_fixup_clone(dict_fixup_ctx_t *fctx, char const *filename, int line,
                     char const *ref, size_t ref_len)
 {
        dict_fixup_clone_t *fixup;
+       fr_dict_attr_t const *target;
+
+       /*
+        *      As a quick check, see if the types are compatible.
+        */
+       target= fr_dict_attr_by_oid(NULL, fr_dict_root(da->dict), ref);
+       if (target) {
+               if (target->type != da->type) {
+                       fr_strerror_printf("Clone reference MUST be to an attribute of type '%s' at [%s:%d]",
+                                          fr_table_str_by_value(fr_value_box_type_table, target->type, "<UNKNOWN>"),
+                                          filename, line);
+                       return -1;
+               }
+       }
 
        fixup = talloc(fctx->pool, dict_fixup_clone_t);
        if (!fixup) {