diff options
author | David Storch <david.storch@10gen.com> | 2016-12-05 11:19:48 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-12-09 17:59:52 -0500 |
commit | 7cf929f25638e4ad9525775c8ea0e18f3c86faf5 (patch) | |
tree | 42328072009a72ce73f1c5bffe60f0c36ee0d492 /src/mongo/db/commands/test_commands.cpp | |
parent | 586ac20773ff7dc18cabf329c238bf261e00387d (diff) | |
download | mongo-7cf929f25638e4ad9525775c8ea0e18f3c86faf5.tar.gz |
SERVER-24128 reject embedded null bytes in namespace string parsing
Diffstat (limited to 'src/mongo/db/commands/test_commands.cpp')
-rw-r--r-- | src/mongo/db/commands/test_commands.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 359e97292c5..ccba3bfb41a 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -81,22 +81,20 @@ public: int, string& errmsg, BSONObjBuilder& result) { - string coll = cmdObj["godinsert"].valuestrsafe(); - log() << "test only command godinsert invoked coll:" << coll; - uassert(13049, "godinsert must specify a collection", !coll.empty()); - string ns = dbname + "." + coll; + const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); + log() << "test only command godinsert invoked coll:" << nss.coll(); BSONObj obj = cmdObj["obj"].embeddedObjectUserCheck(); ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock lk(txn->lockState(), dbname, MODE_X); - OldClientContext ctx(txn, ns); + OldClientContext ctx(txn, nss.ns()); Database* db = ctx.db(); WriteUnitOfWork wunit(txn); UnreplicatedWritesBlock unreplicatedWritesBlock(txn); - Collection* collection = db->getCollection(ns); + Collection* collection = db->getCollection(nss); if (!collection) { - collection = db->createCollection(txn, ns); + collection = db->createCollection(txn, nss.ns()); if (!collection) { errmsg = "could not create collection"; return false; |