[CXX-1476] Element search stops prematurely due to missing string length check Created: 24/Nov/17  Updated: 28/Oct/23  Resolved: 06/Dec/17

Status: Closed
Project: C++ Driver
Component/s: BSON
Affects Version/s: 3.2.0-rc0
Fix Version/s: 3.2.0-rc1

Type: Bug Priority: Blocker - P1
Reporter: Denis Bip Assignee: Andrew Morrow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

debian 9


Issue Links:
Problem/Incident
is caused by CXX-992 bsoncxx::document::view::find() shoul... Closed
Related
related to CDRIVER-2414 bson_iter{_init}_find should have len... Closed
Backwards Compatibility: Fully Compatible

 Description   

Hi! After upgrading driver I cant parse oplog documents which contains "$set". Example:
json print { "op" : "u", "o" : { "$set" :

{ "a" : 1 }

}}
after getting element "o" it becomes utf8 and contains "u"



 Comments   
Comment by Githook User [ 06/Dec/17 ]

Author:

{'name': 'Andrew Morrow', 'username': 'acmorrow', 'email': 'acm@mongodb.com'}

Message: CXX-1476 Handle searches for empty key names correctly

Also, adds a regression test for CXX-1476
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/52c56be1eb266a9fcafc7df7ef8124a93458be6b

Comment by Githook User [ 06/Dec/17 ]

Author:

{'name': 'Andrew Morrow', 'username': 'acmorrow', 'email': 'acm@mongodb.com'}

Message: CXX-1476 Handle searches for empty key names correctly

Also, adds a regression test for CXX-1476
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/52c56be1eb266a9fcafc7df7ef8124a93458be6b

Comment by Githook User [ 06/Dec/17 ]

Author:

{'name': 'kevin1018', 'username': 'kevin1018', 'email': 'wangxk1028@gmail.com'}

Message: CXX-1476 Fix compare key name error

If a document has a "de" key and a "desc" key, when searching for the "de" key, it may match the "desc" key.
So judge the key length to make sure match the right key.
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/c80ce3e8638975baa0f82aa54e28ce416896b219

Comment by Denis Bip [ 04/Dec/17 ]

Hi! Thank's! https://github.com/mongodb/mongo-cxx-driver/pull/607 is not my issue

Comment by Andrew Morrow (Inactive) [ 02/Dec/17 ]

denbip - I did a little digging - and I think this issue was introduced during the changes for CXX-992.

Comment by Andrew Morrow (Inactive) [ 02/Dec/17 ]

Hi denbip -

First, thank you for testing out the release candidate. We really appreciate it and also appreciate your taking the time to report issues you have encountered.

I'm having a little trouble understanding exactly what problem you are encountering from the description in this ticket, but I think that what you are saying is that when you ask for the o element you are actually getting the op element, in which case, does this PR address your issue: https://github.com/mongodb/mongo-cxx-driver/pull/607? If so, are you the author? Is that what you mean by "return old code back?", or something else.

Comment by Denis Bip [ 24/Nov/17 ]

So, I found issue. It is view::const_iterator view::find(stdx::string_view key) const, I've return old code back and now it works

Comment by Denis Bip [ 24/Nov/17 ]

It seems something wrong with operator[] in bsoncxx::document::element

Comment by Denis Bip [ 24/Nov/17 ]

Also it doesnt work with arrays. Example:
{ "_id" :

{ "$oid" : "58dcc9b7c45a4e05d33fa85e" }

, "id_client" : 24, "code_id" :

{ "$oid" : "58dcadd1c45a4e67e04a78df" }

, "code" : [ { "_id" :

{ "$oid" : "58dcadd1c45a4e67e04a78df" }

, "seria" : "EEE", "number" : "123" } ] }
trying to get ["code"] it returns oid with value "58dcadd1c45a4e67e04a78df", but not an array

Generated at Wed Feb 07 22:02:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.