From: Alan T. DeKok Date: Thu, 21 Jul 2022 18:27:05 +0000 (-0400) Subject: error if the VP to add is already in a list X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b34071a52e5f6f38499c654e50e8d02dd826fab5;p=thirdparty%2Ffreeradius-server.git error if the VP to add is already in a list and remove "b" from the old list before adding it to the new one --- diff --git a/src/lib/util/edit.c b/src/lib/util/edit.c index 5c17fad18b6..52154ea92bb 100644 --- a/src/lib/util/edit.c +++ b/src/lib/util/edit.c @@ -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)