Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid pointer returned if reallocate fails in ensure function #189

Closed
timothyjohncarney opened this issue Jul 12, 2017 · 2 comments
Closed

Comments

@timothyjohncarney
Copy link

https://github.com/DaveGamble/cJSON/blob/master/cJSON.c#L379

The calls to reallocate is assumed to return a valid pointer. If it fails, NULL should be returned instead of newbuffer + p->offset.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jul 12, 2017

This is definitely a bug and most likely also a security issue, since an attacker could make realloc fail at exactly the right moment while also providing a big JSON (big offset), thereby potentially producing a pointer to an arbitrary memory address that will be written to by cJSON later on.

I will fix it immediately and create a new bugfix release.

@FSMaxB FSMaxB closed this as completed in 954d61e Jul 12, 2017
@FSMaxB
Copy link
Collaborator

FSMaxB commented Jul 12, 2017

Fixed in Release 1.5.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants