[SERVER-3601] Create collection command should check type of argument Created: 15/Aug/11  Updated: 11/Jul/16  Resolved: 15/Aug/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File create.patch    
Operating System: ALL
Participants:

 Description   

Currently assumes it is a string without checking. This causes the following commands to treat garbage memory as strings. I haven't been able to crash the server with this, but I do get some odd collection names:

> db.runCommand(

{create:true}

)

{ "ok" : 1 }

> db.runCommand(

{create:null}

)

{ "ok" : 1 }

> db.createCollection() // same as

{create:undefined} { "ok" : 1 }

> show tables
Status // from create:true
n( // from create: null
ped // from createCollection()

see attached one-line patch for an easy fix which gives a helpful message:

> db.createCollection()
{
"errmsg" : "exception: must pass name of collection to create",
"code" : 15888,
"ok" : 0
}


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