]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't set flags.internal here.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 20 Mar 2023 15:30:12 +0000 (11:30 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 20 Mar 2023 16:19:04 +0000 (12:19 -0400)
The dictionary code should do this, as per the previous commit.

The tmpl tokenizer has no business mangling the internals of the
attribute structures

src/lib/server/tmpl_tokenize.c

index 4407d07514c3e39c58bce4d78d19867cdf8cd172..e5f524bc51a01dd3a35dd01a2be70c9db0fd18b8 100644 (file)
@@ -1701,8 +1701,6 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
         *      .<oid>
         */
        if (fr_sbuff_out(NULL, &oid, name) > 0) {
-               fr_dict_attr_t *da_unknown;
-
                fr_strerror_clear();    /* Clear out any existing errors */
 
                /*
@@ -1725,7 +1723,6 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                                .ar_parent = our_parent,
                        };
                        vpt->data.attribute.was_oid = true;
-
                        goto check_attr;
                }
 
@@ -1736,38 +1733,29 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                        goto error;
                }
 
-               MEM(ar = talloc(ctx, tmpl_attr_t));
                switch (namespace->type) {
                case FR_TYPE_VSA:
-                       da_unknown = fr_dict_unknown_vendor_afrom_num(ar, namespace, oid);
-                       if (!da_unknown) {
-                               if (err) *err = TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED;    /* strerror set by dict function */
-                               goto error;
-                       }
+                       da = fr_dict_unknown_vendor_afrom_num(ar, namespace, oid);
                        break;
 
                default:
-                       da_unknown = fr_dict_unknown_attr_afrom_num(ar, namespace, oid);
-                       if (!da_unknown) {
-                               if (err) *err = TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED;    /* strerror set by dict function */
-                               goto error;
-                       }
+                       da  = fr_dict_unknown_attr_afrom_num(ar, namespace, oid);
                        break;
                }
 
-               /*
-                *      Inherit the internal flag from our parent.
-                */
-               da_unknown->flags.internal = our_parent->flags.internal;
+               if (!da) {
+                       if (err) *err = TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED;    /* strerror set by dict function */
+                       goto error;
+               }
 
+               MEM(ar = talloc(ctx, tmpl_attr_t));
                *ar = (tmpl_attr_t){
                        .ar_num = NUM_UNSPEC,
                        .ar_type = TMPL_ATTR_TYPE_UNKNOWN,
-                       .ar_unknown = da_unknown,
-                       .ar_da = da_unknown,
+                       .ar_unknown = UNCONST(fr_dict_attr_t *, da),
+                       .ar_da = da,
                        .ar_parent = our_parent,
                };
-               da = da_unknown;
                vpt->data.attribute.was_oid = true;
                goto do_suffix;
        }