[SERVER-11968] Write commands allow illegal collection names Created: 05/Dec/13  Updated: 11/Jul/16  Resolved: 09/Dec/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.5.4
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Christian Amor Kvalheim Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Steps To Reproduce:

//
// Ensures that mongod respects the batch write protocols
//
 
var collectionName = "batch_write_protocol";
var coll = db.getCollection(collectionName);
 
jsTest.log("Starting insert tests...");
 
coll.remove({});
 
var request;
var result;
 
// Drop collection
coll.dropIndexes();
coll.drop();
 
//
// Illegal collection name should fail
var illegalCollectionName = "A\0Z";
request = {insert : illegalCollectionName, documents : [{a : 1}], writeConcern:{w:1}, ordered: true};
result = coll.runCommand(request)
assert.eq(0, result.ok);
assert.eq('number', typeof result.code);
assert.eq('string', typeof result.errmsg);
 
request = {update : illegalCollectionName, updates: [
	{q: {a:1}, u: {$set: {a:1}, upsert:true}}
], writeConcern:{w:1}, ordered:true};
result = coll.runCommand(request)
assert.eq(0, result.ok);
assert.eq('number', typeof result.code);
assert.eq('string', typeof result.errmsg);
 
request = {delete : illegalCollectionName, deletes: [
	{q:{a:1}, top:0}
], writeConcern:{w:1}, ordered:true};
result = coll.runCommand(request)
assert.eq(0, result.ok);
assert.eq('number', typeof result.code);
assert.eq('string', typeof result.errmsg);

Participants:

 Description   

null bytes in collection name does not trigger an error

result after running the test

> show dbs
local  0.078GB
test   0.078GB
admin  (empty)
> use test
switched to db test
> show collections
A
batch_write_protocol
system.indexes



 Comments   
Comment by Githook User [ 09/Dec/13 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-11968 Write commands allow illegal collection names
Branch: master
https://github.com/mongodb/mongo/commit/5a741123578072e0439f8b3b837f43643b809e0b

Generated at Thu Feb 08 03:27:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.