]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't sort if the list is already flat.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 22 Aug 2023 13:01:55 +0000 (09:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 22 Aug 2023 14:13:12 +0000 (10:13 -0400)
That breaks things due to key fields + child structs

src/lib/util/pair.c

index a29b9aa226ae41ad948b47ee00b57194ceb6097c..8c1612d79bbc39bb3d30c3f27a556f35d3407a02 100644 (file)
@@ -3325,8 +3325,21 @@ bool fr_pair_matches_da(void const *item, void const *uctx)
  */
 static void pair_list_flatten(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t *from)
 {
+       bool skip = true;
        fr_pair_t *vp, *next;
 
+       /*
+        *      If the list is already flat, don't do anything.
+        */
+       for (vp = fr_pair_list_head(from); vp; vp = fr_pair_list_next(from, vp)) {
+               if (fr_type_is_structural(vp->vp_type)) {
+                       skip = false;
+                       break;
+               }
+       }
+
+       if (skip) return;
+
        /*
         *      Sort the source list before flattening it.  This is
         *      really necessary only for struct and tlv types.  But