-
-
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
If a string has too many invalid UTF-8 characters, json::dump attempts to index an array out of bounds. #1445
Comments
dgavedissian
changed the title
If a string has too many invalid UTF-8 characters, json::dump indexes an array out of bounds.
If a string has too many invalid UTF-8 characters, json::dump attempts to index an array out of bounds.
Jan 18, 2019
4 tasks
Thanks for reporting! |
nlohmann
added a commit
that referenced
this issue
Jan 20, 2019
attempt to fix #1445, flush buffer in serializer::dump_escaped in UTF8_REJECT case.
dnsmichi
pushed a commit
to Icinga/icinga2
that referenced
this issue
Dec 13, 2019
This includes the following fixes: nlohmann/json#1436 > For a deeply-nested JSON object, the recursive implementation of json_value::destroy function causes stack overflow. nlohmann/json#1708 nlohmann/json#1722 Stack size nlohmann/json#1693 (comment) Integer Overflow nlohmann/json#1447 UTF8, json dump out of bounds nlohmann/json#1445 Possibly influences #7532
This was referenced Dec 13, 2019
Al2Klimov
pushed a commit
to Icinga/icinga2
that referenced
this issue
Dec 16, 2019
This includes the following fixes: nlohmann/json#1436 > For a deeply-nested JSON object, the recursive implementation of json_value::destroy function causes stack overflow. nlohmann/json#1708 nlohmann/json#1722 Stack size nlohmann/json#1693 (comment) Integer Overflow nlohmann/json#1447 UTF8, json dump out of bounds nlohmann/json#1445 Possibly influences #7532
N-o-X
pushed a commit
to Icinga/icinga2
that referenced
this issue
May 8, 2020
This includes the following fixes: nlohmann/json#1436 > For a deeply-nested JSON object, the recursive implementation of json_value::destroy function causes stack overflow. nlohmann/json#1708 nlohmann/json#1722 Stack size nlohmann/json#1693 (comment) Integer Overflow nlohmann/json#1447 UTF8, json dump out of bounds nlohmann/json#1445 Possibly influences #7532
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the issue you have?
On Windows, with a specifically crafted JSON string object (initialised with std::string), json::dump crashes if
ensure_ascii
is set to true, and the error handler is set toerror_handler_t::replace
. Looking at the stack trace, it appears thatdump_escaped
insideserializer.hpp
doesn't do any bounds checking inside theUTF8_REJECT
case forstring_buffer
, which is hardcoded to be exactly 512 bytes.Please describe the steps to reproduce the issue. Can you provide a small but working code example?
Compile and run the following code on Windows (with optimisations disabled and in debug mode):
What is the expected behavior?
It works fine.
And what is the actual behavior instead?
It crashes on serializer.hpp on line 445 (in debug mode). The state of the local variables are:
The stack trace is:
Which compiler and operating system are you using? Is it a supported compiler?
Windows 10. Visual Studio 2015 (latest version).
Did you use a released version of the library or the version from the
develop
branch?Version 3.5.0
If you experience a compilation error: can you compile and run the unit tests?
Yes. All pass with Visual Studio 2015.
The text was updated successfully, but these errors were encountered: