Skip to content

Commit

Permalink
Need to verify config items too
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Apr 27, 2014
1 parent e924058 commit 39562e0
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions src/main/util.c
Expand Up @@ -1178,14 +1178,44 @@ char const *rad_radacct_dir(void)
}

#ifndef NDEBUG

/*
* Verify a packet.
* Verify a pair list
*/
static void verify_packet(REQUEST *request, RADIUS_PACKET *packet)
static void verify_list(TALLOC_CTX *expected, VALUE_PAIR *vps)
{
vp_cursor_t cursor;
void *parent;
VALUE_PAIR *vp;
TALLOC_CTX *parent;

for (vp = fr_cursor_init(&cursor, &vps);
vp;
vp = fr_cursor_next(&cursor)) {
VERIFY_VP(vp);

parent = talloc_parent(vp);
if (expected && (parent != expected)) {
ERROR("Expected VALUE_PAIR (%s) to be parented by %p (%s), "
"but parented by %p (%s)",
vp->da->name,
expected, talloc_get_name(expected),
parent, parent ? talloc_get_name(parent) : "NULL");

fr_log_talloc_report(expected);
if (parent) fr_log_talloc_report(parent);

rad_assert(0);
}

}
}

/*
* Verify a packet.
*/
static void verify_packet(REQUEST *request, RADIUS_PACKET *packet)
{
TALLOC_CTX *parent;

if (!packet) return;

Expand All @@ -1206,26 +1236,7 @@ static void verify_packet(REQUEST *request, RADIUS_PACKET *packet)

if (!packet->vps) return;

for (vp = fr_cursor_init(&cursor, &packet->vps);
vp;
vp = fr_cursor_next(&cursor)) {
VERIFY_VP(vp);

parent = talloc_parent(vp);
if (parent != packet) {
ERROR("Expected VALUE_PAIR (%s) to be parented by %p (%s), "
"but parented by %p (%s)",
vp->da->name,
packet, talloc_get_name(packet),
parent, parent ? talloc_get_name(parent) : "NULL");

fr_log_talloc_report(packet);
if (parent) fr_log_talloc_report(parent);

rad_assert(0);
}

}
verify_list(packet, packet->vps);
}

/*
Expand All @@ -1237,6 +1248,8 @@ void verify_request(REQUEST *request)

(void) talloc_get_type_abort(request, REQUEST);

verify_list(request, request->config_items);

if (request->packet) verify_packet(request, request->packet);
if (request->reply) verify_packet(request, request->reply);
#ifdef WITH_PROXY
Expand Down

0 comments on commit 39562e0

Please sign in to comment.