-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Two questions about the function of ensure
and print
#230
Comments
Thanks for your code review. I will have a closer look at all the calls to Since some of these off by one errors could potentially have security implications, I will make a new release as fast as possible. |
Looking at your examples in detail, there are 2 noncritical bugs and one Off-By-One error that could lead to an out of bound write of one byte. The other lines of code are correct. I will look through everything else again to be more confident that there is nothing more though. 1This definitely looks like an off by one error: Line 515 in 984dc85
This is correct, because Line 1451 in 984dc85
This again is correct, because Line 1641 in 984dc85
The next one is also correct, because no Line 1661 in 984dc85
2This is definitely a bug (not assigning the length to Lines 1095 to 1102 in 984dc85
Also a bug, this makes reallocating completely pointless: Line 1114 in 984dc85
|
I didn't find anything else, except some places where |
Thanks @liuyunbin for reporting this in #230
Thanks @liuyunbin for reporting this in #230
Thanks @liuyunbin for reporting this in #230
Fixed in Release 1.7.1 |
You are right. And I think the line Line 384 in 984dc85
should be the line Line 396 in 984dc85
needed += p->offset;
the line Line 1127 in 984dc85
memcpy(printed, buffer->buffer, buffer->offset + 1));
Because |
Thanks for the further review.
Well the
No, for the same reason. If
This |
In
static unsigned char* ensure(printbuffer * const p, size_t needed)
,needed
whether include'\0'
? IncJSON.c
, most caseneeded
include'\0'
, but the line of515
,1451
,1641
,1661
,needed
don't include'\0'
.In
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
, about line1098
should addbuffer->length = 256;
, the line1114
should beprinted = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
, in my opinion.I'm sorry for my poor English.
The text was updated successfully, but these errors were encountered: