summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/copydb_start_commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/copydb_start_commands.cpp')
-rw-r--r--src/mongo/db/commands/copydb_start_commands.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp
index 3e7f0ee7e60..3dc9769024a 100644
--- a/src/mongo/db/commands/copydb_start_commands.cpp
+++ b/src/mongo/db/commands/copydb_start_commands.cpp
@@ -176,7 +176,15 @@ public:
int,
string& errmsg,
BSONObjBuilder& result) {
- const string fromDb = cmdObj.getStringField("fromdb");
+ const auto fromdbElt = cmdObj["fromdb"];
+ uassert(ErrorCodes::TypeMismatch,
+ "'renameCollection' must be of type String",
+ fromdbElt.type() == BSONType::String);
+ const string fromDb = fromdbElt.str();
+ uassert(
+ ErrorCodes::InvalidNamespace,
+ str::stream() << "Invalid 'fromdb' name: " << fromDb,
+ NamespaceString::validDBName(fromDb, NamespaceString::DollarInDbNameBehavior::Allow));
string fromHost = cmdObj.getStringField("fromhost");
if (fromHost.empty()) {