cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit 1934059554b9a0971e00f79e96900f422cfdd114
parent cc84a446be20cc283bafdc4d94c050ba1111ac02
Author: Max Bruckner <max@maxbruckner.de>
Date:   Thu, 23 Mar 2017 21:35:24 +0100

ensure: Validate buffer offset

Diffstat:
McJSON.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/cJSON.c b/cJSON.c @@ -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 */