Skip to content

Commit

Permalink
Decode last fragment of extended attrs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 1, 2013
1 parent 88f92be commit f6de7be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/radius.c
Expand Up @@ -3115,7 +3115,7 @@ static ssize_t data2vp_extended(RADIUS_PACKET *packet,
fraglen = attrlen - 2;
frag = data + attrlen;
end = data + packetlen;
fragments = 0;
fragments = 1;
last_frag = false;

while (frag < end) {
Expand All @@ -3138,6 +3138,8 @@ static ssize_t data2vp_extended(RADIUS_PACKET *packet,
head = tail = malloc(fraglen);
if (!head) return -1;

VP_TRACE("Fragments %d, total length %d\n", fragments, (int) fraglen);

/*
* And again, but faster and looser.
*
Expand All @@ -3146,7 +3148,7 @@ static ssize_t data2vp_extended(RADIUS_PACKET *packet,
*/
frag = attr;

while (fragments > 0) {
while (fragments > 0) {
memcpy(tail, frag + 4, frag[1] - 4);
tail += frag[1] - 4;
frag += frag[1];
Expand Down

0 comments on commit f6de7be

Please sign in to comment.