From: Alan T. DeKok Date: Thu, 12 Aug 2021 14:41:02 +0000 (-0400) Subject: do fast-path checks for errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df351940894109b6c4f52b72a485b1e7be2d852d;p=thirdparty%2Ffreeradius-server.git do fast-path checks for errors 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. --- diff --git a/src/lib/util/dict_fixup.c b/src/lib/util/dict_fixup.c index 4ad3b975121..e7e10001214 100644 --- a/src/lib/util/dict_fixup.c +++ b/src/lib/util/dict_fixup.c @@ -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, ""), + filename, line); + return -1; + } + } fixup = talloc(fctx->pool, dict_fixup_clone_t); if (!fixup) {