Skip to content

Check for trailing garbage inside json#80

Closed
tmegow wants to merge 0 commit into
json-parser:masterfrom
tmegow:master
Closed

Check for trailing garbage inside json#80
tmegow wants to merge 0 commit into
json-parser:masterfrom
tmegow:master

Conversation

@tmegow

@tmegow tmegow commented Feb 4, 2019

Copy link
Copy Markdown

A stab at addressing open issue #73

@LB-- LB-- left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

Comment thread json.h Outdated

void json_value_free (json_value *);

int trailing_garbage (const json_char *);

Copy link
Copy Markdown
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.

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

case 'e':

Copy link
Copy Markdown
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
Copy Markdown
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?

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

@DimitriPapadopoulos DimitriPapadopoulos Nov 5, 2021

Copy link
Copy Markdown
Contributor

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?

Comment thread json.c Outdated
return 0;
}
}
if (marker == 'u')

@DimitriPapadopoulos DimitriPapadopoulos Nov 5, 2021

Copy link
Copy Markdown
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 "true" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "true" */ or something similar.

Comment thread json.c Outdated
}
if (marker == 'u')
{
if (*(--ptr) == 'r' && *(--ptr) == 't')

Copy link
Copy Markdown
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.

Comment thread json.c Outdated

return 1;

case 'l':

Copy link
Copy Markdown
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.

Comment thread json.c Outdated
return 1;

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

Copy link
Copy Markdown
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.

3 participants