]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
catch stupidities.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 6 Dec 2021 20:24:16 +0000 (15:24 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 7 Dec 2021 13:32:23 +0000 (08:32 -0500)
A ^= A is wrong
A .= A is wrong
A UNION A --> A
A MERGE A --> A
A := A    --> A

src/lib/util/edit.c

index 87765e45ee6fafa467bd8a63b333d5d5f78b420c..b910200249308d81a3696841cd5a5864d05d7031 100644 (file)
@@ -867,21 +867,37 @@ int fr_edit_list_apply_list_assignment(fr_edit_list_t *el, fr_pair_t *dst, fr_to
                 *      new list.
                 */
        case T_OP_SET:
+               if (&dst->children == src) return 0; /* A := A == A */
+
                if (fr_edit_list_free_pair_children(el, dst) < 0) return -1;
                FALL_THROUGH;
 
        case T_OP_ADD_EQ:
+               if (&dst->children == src) {
+                       fr_strerror_printf("Cannot append list to itself");
+                       return -1;
+               }
+
                COPY;
                return fr_edit_list_insert_list_tail(el, &dst->children, &copy);
 
        case T_OP_PREPEND:
+               if (&dst->children == src) {
+                       fr_strerror_printf("Cannot prepend list to itself");
+                       return -1;
+               }
+
                COPY;
                return fr_edit_list_insert_list_head(el, &dst->children, &copy);
 
        case T_OP_OR_EQ:
+               if (&dst->children == src) return 0; /* A UNION A == A */
+
                return list_union(el, dst, src);
 
        case T_OP_GE:
+               if (&dst->children == src) return 0; /* A MERGE A == A */
+
                return list_merge_lhs(el, dst, src);
 
        default: