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

[Bug Report]: semantic bug in parsing json file #1959

Open
Dongmuliang opened this issue Dec 23, 2022 · 0 comments
Open

[Bug Report]: semantic bug in parsing json file #1959

Dongmuliang opened this issue Dec 23, 2022 · 0 comments
Labels

Comments

@Dongmuliang
Copy link

Contact Details

dliangfun@gmail.com

What happened?

A bug happened!
运行环境: ubuntu 22.04
固件版本: no

Version

master (Default)

What soultions are you seeing the problem on?

No response

Relevant log output

To demonstrate the semantic bug, I use the following code to parse a json text:

const char *s = "{\"a\": true, \"b\": [ null,9999999999999999999999999999999999999999999999912345678901234567]}";
cJSON *root = NULL;

root = cJSON_Parse(s);
if (root == NULL) {
       const char *error_ptr = cJSON_GetErrorPtr();
       printf("error in json data:%s\n", error_ptr);
}

It outputs the error message. However, according to the specification https://www.rfc-editor.org/rfc/rfc7159, JSON parser MUST accept all texts that conform to the JSON grammar.
I have checked it against other parsers, e.g., https://jsonlint.com/, https://github.com/nlohmann/json, etc. All of them accepts the text.
This kind of bug has potential security threats especially when different json parser involved (e.g., client side and server side), it may lead to some unexpected errors (e.g., cause data to get out of sync).

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

No branches or pull requests

1 participant