Skip to content

Commit

Permalink
Include trailing \0 in "used" count. Part of #2051
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Sep 1, 2017
1 parent 33ef04a commit 10db503
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/rlm_rest/rest.c
Expand Up @@ -1781,7 +1781,7 @@ static size_t rest_response_body(void *ptr, size_t size, size_t nmemb, void *use
return t;

default:
if (t > (ctx->alloc - ctx->used)) {
if ((t + 1) > (ctx->alloc - ctx->used) {
ctx->alloc += ((t + 1) > REST_BODY_INIT) ? t + 1 : REST_BODY_INIT;

tmp = ctx->buffer;
Expand All @@ -1795,7 +1795,7 @@ static size_t rest_response_body(void *ptr, size_t size, size_t nmemb, void *use
}
}
strlcpy(ctx->buffer + ctx->used, p, t + 1);
ctx->used += t;
ctx->used += t; /* don't include the trailing zero */

break;
}
Expand Down

0 comments on commit 10db503

Please sign in to comment.