Fix paircopyvp, so we don't break xlat expansions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 14 Aug 2014 22:23:16 +0000 (18:23 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 14 Aug 2014 22:23:30 +0000 (18:23 -0400)
src/lib/valuepair.c

index 46c70a1..2f95e55 100644 (file)
@@ -676,13 +676,6 @@ VALUE_PAIR *paircopyvp(TALLOC_CTX *ctx, VALUE_PAIR const *vp)
 
        memcpy(n, vp, sizeof(*n));
 
-       /*
-        *      Now copy the value
-        */
-       if (vp->type == VT_XLAT) {
-               n->value.xlat = talloc_typed_strdup(n, n->value.xlat);
-       }
-
        n->da = dict_attr_copy(vp->da, true);
        if (!n->da) {
                talloc_free(n);
@@ -691,6 +684,15 @@ VALUE_PAIR *paircopyvp(TALLOC_CTX *ctx, VALUE_PAIR const *vp)
 
        n->next = NULL;
 
+       /*
+        *      If it's an xlat, copy the raw string and return early,
+        *      so we don't pre-expand or otherwise mangle the VALUE_PAIR.
+        */
+       if (vp->type == VT_XLAT) {
+               n->value.xlat = talloc_typed_strdup(n, n->value.xlat);
+               return n;
+       }
+
        switch (vp->da->type) {
        case PW_TYPE_TLV:
        case PW_TYPE_OCTETS: