]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
can't do UNION on structs
authorAlan T. DeKok <aland@freeradius.org>
Mon, 6 Dec 2021 18:25:55 +0000 (13:25 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 7 Dec 2021 13:32:22 +0000 (08:32 -0500)
src/lib/util/edit.c

index f79b3421ee1a226a107c5e744dec73f5fa3028b8..87765e45ee6fafa467bd8a63b333d5d5f78b420c 100644 (file)
@@ -678,6 +678,20 @@ static int list_union(fr_edit_list_t *el, fr_pair_t *dst, fr_pair_list_t *src)
        fr_pair_t *a, *b;
        fr_dcursor_t cursor1, cursor2;
 
+       /*
+        *      Prevent people from doing stupid things.
+        *      While it's technically possible to take a
+        *      UNION of structs, that would work ONLY when
+        *      the two structs had disjoint members.
+        *      e.g. {1, 3, 4} and {2, 5, 6}.  That's too
+        *      complex to check right now, so we punt on the
+        *      problem.
+        */
+       if (dst->type == FR_TYPE_STRUCT) {
+               fr_strerror_printf("Cannot take union of STRUCT data types, it would break the structure");
+               return -1;
+       }
+
        fr_pair_list_sort(&dst->children, fr_pair_cmp_by_parent_num);
        fr_pair_list_sort(src, fr_pair_cmp_by_parent_num);