-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
json parser crash if having a large number integer in message #1602
Comments
It's probably throwing an out of range exception from the parser. How are you catching exceptions? |
Just try and catch . But no error report just crash |
For out of range numbers, exception When in doubt, catch the base class try
{
json::parse(request_post);
}
catch (json::parse_error& e)
{
std::cout << "Parse error:" << e.what() << std::endl;
}
catch (json::out_of_range& e)
{
std::cout << "Out of range:" << e.what() << std::endl;
}
catch (json::exception& e)
{
std::cout << "JSON exception: " << e.what() << std::endl;
}
// not really needed
catch (std::exception& e)
{
std::cout << "Unknown exception" << e.what() << std::endl;
} Note: The |
Thanks |
What is the issue you have?
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
I have a test case running on this json library .
The message is as below
{
"testList": [
{
"id": "160013002243",
"customerNumber": 111000000000000000009999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999977777777777777777777777777777777777774444444444444444444444444444444444444444444444444499999999999999999999999999444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444,
"name": "Alex Test for Json",
},
]
}
Then the json parser crashes even with try-catch in C++.
It could work well if the "customer Number" is string type with "".
I am running on a Linux system on am335x.
Linux version 4.4.19 (jenkins@imvisionfw) (gcc version 5.2.0 (crosstool-NG crosstool-ng-1.22.0) ) #1 PREEMPT Thu May 16 04:11:13 CDT 2019
JSON for Modern C++ version is 3.5.0
The text was updated successfully, but these errors were encountered: