Skip to content

Commit

Permalink
ensure: Validate buffer offset
Browse files Browse the repository at this point in the history
  • Loading branch information
FSMaxB committed Mar 23, 2017
1 parent cc84a44 commit 1934059
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ static unsigned char* ensure(printbuffer * const p, size_t needed, const interna
return NULL;
}

if ((p->length > 0) && (p->offset >= p->length))
{
/* make sure that offset is valid */
return NULL;
}

if (needed > INT_MAX)
{
/* sizes bigger than INT_MAX are currently not supported */
Expand Down

0 comments on commit 1934059

Please sign in to comment.