From: Arran Cudbard-Bell Date: Mon, 18 Feb 2013 20:47:19 +0000 (-0500) Subject: Add context pointer to pairalloc X-Git-Tag: release_3_0_0_beta1~1016 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83fca22da68497eef38a42638f2ff5647275ab0c;p=thirdparty%2Ffreeradius-server.git Add context pointer to pairalloc --- diff --git a/src/include/libradius.h b/src/include/libradius.h index 572348e6afa..e22fe19cacf 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -428,7 +428,7 @@ int rad_vp2attr(const RADIUS_PACKET *packet, const VALUE_PAIR **pvp, uint8_t *ptr, size_t room); /* valuepair.c */ -VALUE_PAIR *pairalloc(const DICT_ATTR *da); +VALUE_PAIR *pairalloc(TALLOC_CTX *ctx, const DICT_ATTR *da); VALUE_PAIR *paircreate(unsigned int attr, unsigned int vendor); int pair2unknown(VALUE_PAIR *vp); void pairfree(VALUE_PAIR **); diff --git a/src/lib/radius.c b/src/lib/radius.c index 1797a17c841..35a60ca1659 100644 --- a/src/lib/radius.c +++ b/src/lib/radius.c @@ -3449,7 +3449,7 @@ static ssize_t data2vp(const RADIUS_PACKET *packet, * And now that we've verified the basic type * information, decode the actual data. */ - vp = pairalloc(da); + vp = pairalloc(NULL, da); if (!vp) return -1; vp->length = datalen; diff --git a/src/lib/valuepair.c b/src/lib/valuepair.c index ab90ec273b5..9914c843c87 100644 --- a/src/lib/valuepair.c +++ b/src/lib/valuepair.c @@ -49,10 +49,11 @@ static const char *months[] = { * * Allocates a new attribute and a new dictionary attr if no DA is provided. * + * @param[in] ctx for allocated memory, usually a pointer to the request. * @param[in] da Specifies the dictionary attribute to build the VP from. * @return a new value pair or NULL if an error occurred. */ -VALUE_PAIR *pairalloc(const DICT_ATTR *da) +VALUE_PAIR *pairalloc(UNUSED void *ctx, const DICT_ATTR *da) { VALUE_PAIR *vp; @@ -102,7 +103,7 @@ VALUE_PAIR *paircreate(unsigned int attr, unsigned int vendor) } } - return pairalloc(da); + return pairalloc(NULL, da); } /** Free memory used by a single valuepair. @@ -383,7 +384,7 @@ VALUE_PAIR *paircopyvpdata(const DICT_ATTR *da, const VALUE_PAIR *vp) if (da->type != vp->da->type) return NULL; - n = pairalloc(da); + n = pairalloc(NULL, da); if (!n) { return NULL; } @@ -1474,7 +1475,7 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value, * it. This next stop also looks the attribute up in the * dictionary, and creates the appropriate type for it. */ - vp = pairalloc(da); + vp = pairalloc(NULL, da); if (!vp) { return NULL; } @@ -1573,7 +1574,8 @@ VALUE_PAIR *pairmake(const char *attribute, const char *value, FR_TOKEN op) return pairmake_any(attrname, value, op); } - if ((vp = pairalloc(da)) == NULL) { + vp = pairalloc(NULL, da); + if (!vp) { return NULL; } diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index 2e36843eb68..a83518a59b1 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -473,7 +473,7 @@ static rlm_cache_entry_t *cache_add(rlm_cache_t *inst, REQUEST *request, fr_int2str(fr_tokens, map->op, "¿unknown?"), buffer); - vp = pairalloc(map->dst->da); + vp = pairalloc(NULL, map->dst->da); if (!vp) continue; vp->op = map->op; @@ -498,7 +498,7 @@ static rlm_cache_entry_t *cache_add(rlm_cache_t *inst, REQUEST *request, fr_int2str(fr_tokens, map->op, "¿unknown?"), map->src->name); - vp = pairalloc(map->dst->da); + vp = pairalloc(NULL, map->dst->da); if (!vp) continue; vp->op = map->op; diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c index 70332915f80..3ee5d01c68d 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c @@ -277,7 +277,7 @@ static VALUE_PAIR *diameter2vp(REQUEST *request, SSL *ssl, if (vp) pairfree(&vp); da = dict_attrunknown(attr, vendor, TRUE); if (!da) return NULL; - vp = pairalloc(da); + vp = pairalloc(NULL, da); if (size >= 253) size = 253; vp->length = size; memcpy(vp->vp_octets, data, vp->length); diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 58c79550d43..f18a3b7054d 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -1629,7 +1629,7 @@ static VALUE_PAIR *ldap_getvalue(REQUEST *request, const value_pair_map_t *map, * just use whatever was set in the attribute map. */ for (i = 0; i < self->count; i++) { - vp = pairalloc(map->dst->da); + vp = pairalloc(NULL, map->dst->da); rad_assert(vp); pairparsevalue(vp, self->values[i]); diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index 5a7d3d4669a..9bf465800be 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -1056,7 +1056,7 @@ static int rest_decode_post(rlm_rest_t *instance, goto skip; } - vp = pairalloc(da); + vp = pairalloc(NULL, da); if (!vp) { radlog(L_ERR, "rlm_rest (%s): Failed creating" " valuepair", instance->xlat_name); diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 3e6ed6f1405..ba1e4e85449 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -473,7 +473,7 @@ int sql_set_user(SQL_INST *inst, REQUEST *request, const char *username) return -1; } - vp = pairalloc(inst->sql_user); + vp = pairalloc(NULL, inst->sql_user); vp->op = T_OP_SET; strlcpy(vp->vp_strvalue, buffer, sizeof(vp->vp_strvalue));