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

Check for trailing garbage inside json #80

Closed
wants to merge 0 commits into from

Conversation

tmegow
Copy link

@tmegow tmegow commented Feb 4, 2019

A stab at addressing open issue #73

Copy link
Member

@LB-- LB-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many formatting/spacing changes that make it difficult to see the actual changed code. Would you be willing to try again without reformatting the source file?

@DimitriPapadopoulos
Copy link
Contributor

@tmegow Could you perhaps discard the indentation and formatting commits? Then, commit Allow for empty objects and empty arrays must be reworked to only bring essential changes.

I'm not saying the current format is perfect, but reformatting everything while adding actual changes is never an option.

json.h Outdated
@@ -266,6 +266,7 @@ json_value * json_parse_ex (json_settings * settings,

void json_value_free (json_value *);

int trailing_garbage (const json_char *);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function need to be declared in json.h? I don't think so, it should be a static function of json.c.

json.c Outdated
case '"':
return 0;

case 'e':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're looking for "false" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "false" */ or something similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then would strncmp() work for all possible types of json_char?

json.c Outdated
marker = *(--ptr);
if (marker == 's')
{
if (*(--ptr) == 'l' && *(--ptr) == 'a' && *(--ptr) == 'f')
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos Nov 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you decrement --ptr multiple times. Are there cases where you could decrement past the beginning of the buffer?

json.c Outdated
return 0;
}
}
if (marker == 'u')
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos Nov 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're looking for "true" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "true" */ or something similar.

json.c Outdated
}
if (marker == 'u')
{
if (*(--ptr) == 'r' && *(--ptr) == 't')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about multiple --ptr.

json.c Outdated

return 1;

case 'l':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're looking for "null" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "null" */ or something similar.

json.c Outdated
return 1;

case 'l':
if (*(--ptr) == 'l' && *(--ptr) == 'u' && *(--ptr) == 'n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about multiple --ptr.

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.

None yet

3 participants