-
Notifications
You must be signed in to change notification settings - Fork 15
Fix mangrove crash #43
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
base: master
Are you sure you want to change the base?
Conversation
Crash observed when document length is 257 byte, for example. It represents as '0x01 01 00 00'. In this case '_bytes_read == _len' equal to 1 and callback is called with partial buffer (only 1 byte actually). This cause later crash in 'to_dotted_notation_document' Signed-off-by: Abylay Ospan <aospan@netup.ru>
@@ -67,7 +67,7 @@ int bson_output_streambuf::insert(int ch) { | |||
} | |||
|
|||
// This creates the document from the given bytes, and calls the user-provided callback. | |||
if (_bytes_read == _len) { | |||
if (_bytes_read == _len && _len > 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about earlier(e..g line 54) just returning early if _bytes_read < 4, so we're never dealing with an invalid _len in the later code?
Wow, good catch! |
@rkargon tnx :) BTW, better to implement: then we shouldn't care about buffer assembly and avoid byte-by-byte copy (which can slow down whole process) |
With mongo-cxx-3.2+ we have exception: terminate called after throwing an instance of 'bsoncxx::v_noabi::exception' what(): can't convert builder to a valid view: unmatched key while using embedded documents. For example: { "name" : "Jenny", "contact_info" : { "type" : "home" } } we have called twice: 1. for "contact_info" key 2. for "contact_info.type" key in mongo-cxx-3.2+ we can't call key_view/key_owned twice. Otherwise we receive exception as described above. Signed-off-by: Abylay Ospan <aospan@netup.ru>
Incorrect fix revert. This reverts commit 4f0c9e9.
With modern mongo-cxx (tested on 3.3.1) we have exception while using embedded documents: terminate called after throwing an instance of 'bsoncxx::v_noabi::exception' what(): can't convert builder to a valid view: unmatched key For example: { "name" : "Jenny", "contact_info" : { "type" : "home" } } we have called twice: 1. for "contact_info" key 2. for "contact_info.type" key we can't call key_view/key_owned twice. Otherwise we receive exception as described above. Signed-off-by: Abylay Ospan <aospan@netup.ru>
This reverts commit 789d683.
With modern mongo-cxx (tested on 3.3.1) we have exception while using embedded documents: terminate called after throwing an instance of 'bsoncxx::v_noabi::exception' what(): can't convert builder to a valid view: unmatched key For example: { "name" : "Jenny", "contact_info" : { "type" : "home" } } we have called twice: 1. for "contact_info" key 2. for "contact_info.type" key we can't call key_view/key_owned twice. Otherwise we receive exception as described above. Signed-off-by: Abylay Ospan <aospan@netup.ru>
Save 'key' if we do not in dot notation mode Signed-off-by: Abylay Ospan <aospan@netup.ru>
Crash observed when document length is 257 byte, for example.
It represents as '0x01 01 00 00'.
In this case '_bytes_read == _len' equal to 1 and callback is called
with partial buffer (only 1 byte actually). This cause later crash in
'to_dotted_notation_document'
Signed-off-by: Abylay Ospan aospan@netup.ru