]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Insert new pair where we were asked to
authorNick Porter <nick@portercomputing.co.uk>
Wed, 6 Sep 2023 11:26:52 +0000 (12:26 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 6 Sep 2023 12:13:22 +0000 (13:13 +0100)
src/lib/util/pair.c

index 6467f58dc2298d3ea725435123f247ee553d9a54..8d8b10a38b56c83517244e2ed9dfc2bffbdc8615 100644 (file)
@@ -3498,7 +3498,15 @@ static fr_pair_t *pair_alloc_parent(fr_pair_t *in, fr_pair_t *item, fr_dict_attr
        vp = fr_pair_afrom_da(parent, da);
        if (!vp) return NULL;
 
-       fr_pair_append(&parent->vp_group, vp);
+       /*
+        *      If we are at the root, and have been provided with
+        *      an entry to insert before, then do that.
+        */
+       if (item && da->parent->flags.is_root) {
+               fr_pair_insert_before(&parent->vp_group, item, vp);
+       } else {
+               fr_pair_append(&parent->vp_group, vp);
+       }
        return vp;
 }