Skip to content

Commit

Permalink
Fix a rare edge case in the rlm_rest POST encoder
Browse files Browse the repository at this point in the history
If there are additional attributes to encode, and there is exactly one byte free in the output buffer, then we lose the value of the previously encoded attribute.
  • Loading branch information
arr2036 committed Jan 12, 2021
1 parent b2adf9c commit 3dd36aa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/modules/rlm_rest/rest.c
Expand Up @@ -652,10 +652,19 @@ static size_t rest_encode_post(void *out, size_t size, size_t nmemb, void *userd
/*
* there are more attributes, insert a separator
*/
if (fr_cursor_next(&ctx->cursor)) {
if (fr_cursor_next_peek(&ctx->cursor)) {
if (freespace < 1) goto no_space;
*p++ = '&';
freespace--;
/*
* Only advance once we have a separator
* really we should have an additional
* state for encoding the separator,
* but, we don't, and v3.0.x is stable
* so let's do the easiest fix with the
* lowest risk.
*/
fr_cursor_next(&ctx->cursor);
}

/*
Expand Down

0 comments on commit 3dd36aa

Please sign in to comment.