From: Alan T. DeKok Date: Mon, 18 Feb 2013 16:24:39 +0000 (-0500) Subject: Simplify copying of xlat value X-Git-Tag: release_3_0_0_beta1~1052 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=186594ebe62985322e758d16b2a5d8e694866dcc;p=thirdparty%2Ffreeradius-server.git Simplify copying of xlat value --- diff --git a/src/lib/valuepair.c b/src/lib/valuepair.c index 975a52494c8..24eba99b57a 100644 --- a/src/lib/valuepair.c +++ b/src/lib/valuepair.c @@ -129,7 +129,7 @@ void pairbasicfree(VALUE_PAIR *pair) { char *tmp; - memcpy(&tmp, pair->value.xlat, sizeof(tmp)); + memcpy(&tmp, &pair->value.xlat, sizeof(tmp)); free(tmp); } default: @@ -342,23 +342,13 @@ VALUE_PAIR *paircopyvp(const VALUE_PAIR *vp) /* * Now copy the value */ - switch (vp->type) - { - case VT_XLAT: - n->type = VT_NONE; - - if (pairmark_xlat(n, vp->value.xlat) < 0) { - pairbasicfree(n); - return NULL; - } - break; - default: - break; + if (vp->type == VT_XLAT) { + n->value.xlat = strdup(n->value.xlat); } n->da = dict_attr_copy(vp->da, TRUE); if (!n->da) { - free(n); + pairbasicfree(n); return NULL; } @@ -398,27 +388,13 @@ VALUE_PAIR *paircopyvpdata(const DICT_ATTR *da, const VALUE_PAIR *vp) return NULL; } - /* - * Now copy the value - */ - switch (n->type) - { - case VT_XLAT: - n->type = VT_NONE; - - if (pairmark_xlat(n, vp->value.xlat) < 0) { - pairbasicfree(n); - return NULL; - } - break; - default: - break; + memcpy(n, vp, sizeof(*n)); + n->da = da; + + if (n->type == VT_XLAT) { + n->value.xlat = strdup(n->value.xlat); } - memcpy(&(n->data), &(vp->data), sizeof(n->data)); - - n->length = vp->length; - if ((n->da->type == PW_TYPE_TLV) && (n->vp_tlv != NULL)) { n->vp_tlv = malloc(n->length);