diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-30 14:23:30 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-30 16:47:02 -0400 |
commit | e45aba42f783cf2e2974b7ea6944a6c81b0a6be4 (patch) | |
tree | c15fc1c8be8aaeead074ede66ea695847464c794 | |
parent | 2a09ba86b4812c37ea167328dbf528bd1c245b4e (diff) | |
download | mongo-e45aba42f783cf2e2974b7ea6944a6c81b0a6be4.tar.gz |
SERVER-23434 Make find and getMore return InvalidNamespace on bad namespaces
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/query/find.cpp | 6 | ||||
-rw-r--r-- | src/mongo/dbtests/directclienttests.cpp | 4 |
4 files changed, 11 insertions, 9 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 5610c4799db..82c63c01cf8 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -126,8 +126,7 @@ public: ExplainCommon::Verbosity verbosity, const rpc::ServerSelectionMetadata&, BSONObjBuilder* out) const override { - const std::string fullns = parseNs(dbname, cmdObj); - const NamespaceString nss(fullns); + const NamespaceString nss(parseNs(dbname, cmdObj)); if (!nss.isValid()) { return {ErrorCodes::InvalidNamespace, str::stream() << "Invalid collection name: " << nss.ns()}; @@ -183,8 +182,7 @@ public: int options, std::string& errmsg, BSONObjBuilder& result) override { - const std::string fullns = parseNs(dbname, cmdObj); - const NamespaceString nss(fullns); + const NamespaceString nss(parseNs(dbname, cmdObj)); if (!nss.isValid() || nss.isCommand() || nss.isSpecialCommand()) { return appendCommandStatus(result, {ErrorCodes::InvalidNamespace, diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 3e837b801a9..d3cac033950 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -915,7 +915,9 @@ bool receivedGetMore(OperationContext* txn, DbResponse& dbresponse, Message& m, try { const NamespaceString nsString(ns); - uassert(16258, str::stream() << "Invalid ns [" << ns << "]", nsString.isValid()); + uassert(ErrorCodes::InvalidNamespace, + str::stream() << "Invalid ns [" << ns << "]", + nsString.isValid()); Status status = AuthorizationSession::get(txn->getClient()) ->checkAuthForGetMore(nsString, cursorid, false); diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index 241943f5fe1..edc77d515bf 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -489,8 +489,10 @@ std::string runQuery(OperationContext* txn, const NamespaceString& nss, Message& result) { CurOp& curop = *CurOp::get(txn); - // Validate the namespace. - uassert(16256, str::stream() << "Invalid ns [" << nss.ns() << "]", nss.isValid()); + + uassert(ErrorCodes::InvalidNamespace, + str::stream() << "Invalid ns [" << nss.ns() << "]", + nss.isValid()); invariant(!nss.isCommand()); // Set curop information. diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp index 98e94d705ec..fd32e9b57d1 100644 --- a/src/mongo/dbtests/directclienttests.cpp +++ b/src/mongo/dbtests/directclienttests.cpp @@ -133,7 +133,7 @@ public: ASSERT(cursor->more()); BSONObj result = cursor->next().getOwned(); ASSERT(result.hasField("$err")); - ASSERT_EQUALS(result["code"].Int(), 16256); + ASSERT_EQUALS(result["code"].Int(), ErrorCodes::InvalidNamespace); } }; @@ -147,7 +147,7 @@ public: ASSERT(cursor->more()); BSONObj result = cursor->next().getOwned(); ASSERT(result.hasField("$err")); - ASSERT_EQUALS(result["code"].Int(), 16258); + ASSERT_EQUALS(result["code"].Int(), ErrorCodes::InvalidNamespace); } }; |