Skip to content

Commit

Permalink
SERVER-19928 Find command should reject requests to read special comm…
Browse files Browse the repository at this point in the history
…and namespaces
  • Loading branch information
coollog committed Aug 14, 2015
1 parent a93377f commit 9860212
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions jstests/noPassthroughWithMongod/find_cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ assert.commandFailed(coll.runCommand("find", {foo: "bar"}));

// Filter doesn't parse.
assert.commandFailed(coll.runCommand("find", {projection: {_id: 0}, filter: {$foo: "bar"}}));

// Special command namespace.
assert.commandFailed(coll.getDB().runCommand({find: "$cmd"}));
assert.commandFailed(coll.getDB().runCommand({find: "$cmd.sys.inprog"}));
2 changes: 1 addition & 1 deletion src/mongo/db/commands/find_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class FindCmd : public Command {
BSONObjBuilder& result) override {
const std::string fullns = parseNs(dbname, cmdObj);
const NamespaceString nss(fullns);
if (!nss.isValid()) {
if (!nss.isValid() || nss.isCommand() || nss.isSpecialCommand()) {
return appendCommandStatus(result,
{ErrorCodes::InvalidNamespace,
str::stream() << "Invalid collection name: " << nss.ns()});
Expand Down

0 comments on commit 9860212

Please sign in to comment.