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

fix fail to catch last backslash # 780 #782

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lxltiger
Copy link

@lxltiger lxltiger commented Sep 5, 2023

static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer)
{
...
// this does not work
if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length)
{
/* prevent buffer overflow when last input character is a backslash */
goto fail;
}
...
}
image

As show above , when last input character is a backslash.The index of input_end is always input_buffer->length - 2.
So input_end + 1 - input_buffer->content >= input_buffer->length will never come true。

Maybe we should minus 1 in the right:
input_end + 1 - input_buffer->content >= input_buffer->length-1

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

Successfully merging this pull request may close these issues.

1 participant