]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
error if the VP to add is already in a list
authorAlan T. DeKok <aland@freeradius.org>
Thu, 21 Jul 2022 18:27:05 +0000 (14:27 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 23 Jul 2022 23:47:17 +0000 (19:47 -0400)
and remove "b" from the old list before adding it to the new one

src/lib/util/edit.c

index 5c17fad18b6b3165fda0d100b41032a9e26155f9..52154ea92bb6f90cfa6734b032b21bd2df0cb250 100644 (file)
@@ -419,6 +419,7 @@ static int edit_record(fr_edit_list_t *el, fr_edit_op_t op, fr_pair_t *vp, fr_pa
 
        switch (op) {
        case FR_EDIT_INVALID:
+       fail:
                talloc_free(e);
                return -1;
 
@@ -447,7 +448,7 @@ static int edit_record(fr_edit_list_t *el, fr_edit_op_t op, fr_pair_t *vp, fr_pa
                 *      just delete this pair from the list.
                 */
                e->list = list;
-               fr_pair_insert_after(list, ref, vp);
+               if (fr_pair_insert_after(list, ref, vp) < 0) goto fail;
                break;
 
        case FR_EDIT_DELETE:
@@ -775,6 +776,7 @@ int fr_edit_list_apply_pair_assignment(fr_edit_list_t *el, fr_pair_t *vp, fr_tok
                        if (!c) return -1; \
                       } else { \
                        c = talloc_steal(dst, _x); \
+                       fr_pair_remove(src, c); \
                      } \
                 } while (0)