Depending on where the null characters appear and how many of them there are, you get different errors. Here's one reproducible case using Java:
DBCollection c = m.getDB("test").getCollection("CS4355"); String s = URLDecoder.decode("/students?%2500%16%00%00%00%02hello%00%06%00%00%00world%00%00=%2500", "UTF-8"); DBObject obj = new BasicDBObject("embedded", new BasicDBObject(s, 1)); c.insert(obj, WriteConcern.SAFE); DBObject objOut = c.findOne(obj); System.out.println(objOut);
The insert returns normally, but the call to findOne throws an exception:
Exception in thread "main" com.mongodb.MongoException: BSONElement: bad type 101 at com.mongodb.MongoException.parse(MongoException.java:82) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:293) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:274) at com.mongodb.DBCollection.findOne(DBCollection.java:710) at com.mongodb.DBCollection.findOne(DBCollection.java:652) at CS4355.main(CS4355.java:39)
and validate fails as well:
Mon Sep 10 20:56:55 [conn2] runQuery called test.$cmd { validate: "CS4355", full: true } Mon Sep 10 20:56:55 [conn2] run command test.$cmd { validate: "CS4355", full: true } Mon Sep 10 20:56:55 [conn2] CMD: validate test.CS4355 Mon Sep 10 20:56:55 [conn2] Assertion: 13655:BSONElement: bad type 101 0x10007fd6c 0x1000082ad 0x1000162a1 0x10001632e 0x1004ab99f 0x1004adce6 0x10048c3a4 0x10048cd76 0x10045457b 0x10045600a 0x1003a6b61 0x1003a7b02 0x1005a678f 0x1001387ad 0x1005b2af9 0x7fff86d6d782 0x7fff86d5a1c1 0 mongod 0x000000010007fd6c _ZN5mongo11msgassertedEiPKc + 396 1 mongod 0x00000001000082ad _ZNK5mongo11BSONElement4sizeEi + 461 2 mongod 0x00000001000162a1 _ZNK5mongo7BSONObj5validEv + 177 3 mongod 0x000000010001632e _ZNK5mongo7BSONObj5validEv + 318 4 mongod 0x00000001004ab99f _ZN5mongo11ValidateCmd10validateNSEPKcPNS_16NamespaceDetailsERKNS_7BSONObjERNS_14BSONObjBuilderE + 6543 5 mongod 0x00000001004adce6 _ZN5mongo11ValidateCmd3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb + 518 6 mongod 0x000000010048c3a4 _ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb + 2692 7 mongod 0x000000010048cd76 _ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 694 8 mongod 0x000000010045457b _ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 59 9 mongod 0x000000010045600a _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 5818 10 mongod 0x00000001003a6b61 _ZN5mongoL13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 337 11 mongod 0x00000001003a7b02 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1458 12 mongod 0x00000001005a678f _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 271 13 mongod 0x00000001001387ad _ZN5mongo3pms9threadRunEPNS_13MessagingPortE + 605 14 mongod 0x00000001005b2af9 thread_proxy + 137 15 libsystem_c.dylib 0x00007fff86d6d782 _pthread_start + 327 16 libsystem_c.dylib 0x00007fff86d5a1c1 thread_start + 13 Mon Sep 10 20:56:55 [conn2] Invalid bson detected in test.CS4355 with _id: ObjectId('504e8c4e57862e8db678a9a2')
- duplicates
-
DRIVERS-101 BSON cstring with null bytes should not be allowed
- Closed
- is depended on by
-
SERVER-23164 Updates with null characters in key names can break replication
- Closed
- related to
-
SERVER-23567 Fetcher should blacklist sources that return unexpected errors
- Closed
-
SERVER-23858 server22767.js in noPassthrough suite is failing due to checking for wrong error code
- Closed