Allow expansions while we're processing the list.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 29 Jun 2015 12:16:49 +0000 (08:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 29 Jun 2015 12:16:49 +0000 (08:16 -0400)
By the horrible hack of making a copy of the input list.
The issue is that the expansions need access to the input list,
but we also need to re-write the input list in radius_pairmove()

So until we have a better fix, we'll just do this hack

src/main/evaluate.c

index e5a436f..5533b90 100644 (file)
@@ -765,8 +765,10 @@ void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool d
        vp_cursor_t cursor;
        VALUE_PAIR *vp, *next, **last;
        VALUE_PAIR **from_list, **to_list;
+       VALUE_PAIR *to_copy;
        bool *edited = NULL;
        REQUEST *fixup = NULL;
+       TALLOC_CTX *ctx;
 
        if (!request) return;
 
@@ -810,7 +812,9 @@ void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool d
        }
 
        to_count = 0;
-       for (vp = *to; vp != NULL; vp = next) {
+       ctx = talloc_parent(*to);
+       to_copy = paircopy(ctx, *to);
+       for (vp = to_copy; vp != NULL; vp = next) {
                next = vp->next;
                to_list[to_count++] = vp;
                vp->next = NULL;
@@ -1002,7 +1006,7 @@ void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool d
        /*
         *      Re-chain the "to" list.
         */
-       *to = NULL;
+       pairfree(to);
        last = to;
 
        if (to == &request->packet->vps) {