]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't always copy the parsed flag when duping pairs
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 14 May 2024 00:24:51 +0000 (18:24 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 14 May 2024 00:24:51 +0000 (18:24 -0600)
src/lib/server/cf_file.c
src/lib/server/cf_util.c
src/lib/server/cf_util.h

index 51d54f65af2e25c1aca5cafe83b6238b1ac5eaef..bb89744a6691b4b706de4d2ad6e7d34ca37ec745 100644 (file)
@@ -488,7 +488,7 @@ static bool cf_template_merge(CONF_SECTION *cs, CONF_SECTION const *template)
                         *      Create a new pair with all of the data
                         *      of the old one.
                         */
-                       cp2 = cf_pair_dup(cs, cp1);
+                       cp2 = cf_pair_dup(cs, cp1, true);
                        if (!cp2) return false;
 
                        cf_filename_set(cp2, cp1->item.filename);
index 2dfc5a8e6d36bb0d815c0166d69565a44a4a33be..a9bc02401709583f0ff02f5f31bf9ea3ba561583 100644 (file)
@@ -886,7 +886,8 @@ void _cf_lineno_set(CONF_ITEM *ci, int lineno)
  * @param[in] name1    of new section.
  * @param[in] name2    of new section.
  * @param[in] copy_meta        Copy additional meta data for a section
- *                     (like template, base, depth and variables).
+ *                     (like template, base, depth, parsed state,
+ *                     and variables).
  * @return
  *     - A duplicate of the existing section.
  *     - NULL on error.
@@ -922,7 +923,7 @@ CONF_SECTION *cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION
                        break;
 
                case CONF_ITEM_PAIR:
-                       cp = cf_pair_dup(new, cf_item_to_pair(ci));
+                       cp = cf_pair_dup(new, cf_item_to_pair(ci), copy_meta);
                        if (!cp) {
                                talloc_free(new);
                                return NULL;
@@ -940,7 +941,6 @@ CONF_SECTION *cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION
        return new;
 }
 
-
 /** Return the next child that's a #CONF_SECTION
  *
  * @param[in] cs       to return children from.
@@ -1254,11 +1254,12 @@ CONF_PAIR *cf_pair_alloc(CONF_SECTION *parent, char const *attr, char const *val
  *
  * @param parent       to allocate new pair in.
  * @param cp           to duplicate.
+ * @param copy_meta    Copy additional meta data for a pair
  * @return
  *     - NULL on error.
  *     - A duplicate of the input pair.
  */
-CONF_PAIR *cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp)
+CONF_PAIR *cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp, bool copy_meta)
 {
        CONF_PAIR *new;
 
@@ -1268,7 +1269,7 @@ CONF_PAIR *cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp)
        new = cf_pair_alloc(parent, cp->attr, cf_pair_value(cp), cp->op, cp->lhs_quote, cp->rhs_quote);
        if (!new) return NULL;
 
-       new->parsed = cp->parsed;
+       if (copy_meta) new->parsed = cp->parsed;
        cf_lineno_set(new, cp->item.lineno);
        cf_filename_set(new, cp->item.filename);
 
@@ -1303,7 +1304,7 @@ int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
        /*
         *      Add the new CONF_PAIR
         */
-       MEM(new_cp = cf_pair_dup(cs, cp));
+       MEM(new_cp = cf_pair_dup(cs, cp, true));
        talloc_const_free(cp->value);
        MEM(cp->value = talloc_typed_strdup(cp, value));
 
index 087278c95d10f01089977316ed6a7f145779f8c3..4ecbb5f77b72ea4b5962916343e9af49cd3e9fb1 100644 (file)
@@ -182,7 +182,7 @@ void                cf_section_add_name2_quote(CONF_SECTION *cs, fr_token_t token);
 CONF_PAIR      *cf_pair_alloc(CONF_SECTION *parent, char const *attr, char const *value,
                               fr_token_t op, fr_token_t lhs_type, fr_token_t rhs_type);
 
-CONF_PAIR      *cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp);
+CONF_PAIR      *cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp, bool copy_meta);
 
 int            cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, char const *value);