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

attempt to fix #1445, flush buffer in serializer::dump_escaped in UTF8_REJECT case. #1446

Merged
merged 3 commits into from
Jan 20, 2019

Conversation

scinart
Copy link
Contributor

@scinart scinart commented Jan 19, 2019

attempt to fix #1445

serializer use fixed-size buffer. Whenever it is nearly full, it is flushed to output_adapter_t<char> o

But the code forgets to flush when there is an invalid utf8 code point

So there will be buffer overflow.


Pull request checklist

Read the Contribution Guidelines for detailed information.

  • Changes are described in the pull request, or an existing issue is referenced.
  • The test suite compiles and runs without error.
  • Code coverage is 100%. Test cases can be added by editing the test suite.
  • The source code is amalgamated; that is, after making changes to the sources in the include/nlohmann directory, run make amalgamate to create the single-header file single_include/nlohmann/json.hpp. The whole process is described here.

serializer use fixed buffer. Whenever it is nearly full, it is flushed to `output_adapter_t<char> o`
But the code forgets to flush when there is a invalid utf8 code point
So there will be buffer overflow.
@coveralls
Copy link

coveralls commented Jan 19, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 20db020 on scinart:develop into dffae10 on nlohmann:develop.

test/src/unit-invalid_utf8.cpp Outdated Show resolved Hide resolved
Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@nlohmann nlohmann self-assigned this Jan 19, 2019
@nlohmann nlohmann added this to the Release 3.5.1 milestone Jan 19, 2019
@nlohmann nlohmann merged commit e17e0d0 into nlohmann:develop Jan 20, 2019
@nlohmann
Copy link
Owner

Thanks!

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

Successfully merging this pull request may close these issues.

If a string has too many invalid UTF-8 characters, json::dump attempts to index an array out of bounds.
3 participants