Skip to content

Commit

Permalink
map->dst->tmpl_da can be NULL if it's not TMPL_TYPE_ATTR
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Sep 5, 2014
1 parent 2ff306e commit 12aa6e8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/map.c
Expand Up @@ -623,22 +623,32 @@ int map_to_vp(VALUE_PAIR **out, REQUEST *request, value_pair_map_t const *map, U
{
vp_cursor_t from;

rad_assert(!map->dst->tmpl_da ||
(map->src->tmpl_da->type == map->dst->tmpl_da->type) ||
(map->src->tmpl_da->type == PW_TYPE_OCTETS) ||
(map->dst->tmpl_da->type == PW_TYPE_OCTETS));
if (map->dst->type != TMPL_TYPE_ATTR) {
rad_assert(map->dst->tmpl_da == NULL);
} else {
rad_assert(map->dst->tmpl_da != NULL);

/*
* Matching type, OR src/dst is octets.
*/
rad_assert((map->src->tmpl_da->type == map->dst->tmpl_da->type) ||
(map->src->tmpl_da->type == PW_TYPE_OCTETS) ||
(map->dst->tmpl_da->type == PW_TYPE_OCTETS));
}

/*
* @todo should log error, and return -1 for v3.1 (causes update to fail)
*/
if (tmpl_copy_vps(request, &found, request, map->src) < 0) return 0;

vp = fr_cursor_init(&from, &found);

/*
* Src/Dst attributes don't match, convert src attributes
* to match dst.
*/
if (map->src->tmpl_da->type != map->dst->tmpl_da->type) {
if ((map->dst->type == TMPL_TYPE_ATTR) &&
(map->src->tmpl_da->type != map->dst->tmpl_da->type)) {
vp_cursor_t to;

(void) fr_cursor_init(&to, out);
Expand Down

0 comments on commit 12aa6e8

Please sign in to comment.