diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/count_cmd.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/distinct.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 6 | ||||
-rw-r--r-- | src/mongo/idl/idl_parser.cpp | 6 |
5 files changed, 21 insertions, 9 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index cbaeb7f9625..266c05c907c 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -186,6 +186,12 @@ NamespaceString CommandHelpers::parseNsCollectionRequired(StringData dbname, // Accepts both BSON String and Symbol for collection name per SERVER-16260 // TODO(kangas) remove Symbol support in MongoDB 3.0 after Ruby driver audit BSONElement first = cmdObj.firstElement(); + const bool isUUID = (first.canonicalType() == canonicalizeBSONType(mongo::BinData) && + first.binDataType() == BinDataType::newUUID); + uassert(ErrorCodes::InvalidNamespace, + str::stream() << "Collection name must be provided. UUID is not valid in this " + << "context", + !isUUID); uassert(ErrorCodes::InvalidNamespace, str::stream() << "collection name has invalid type " << typeName(first.type()), first.canonicalType() == canonicalizeBSONType(mongo::String)); diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp index 8c08d19091c..cd2891f6266 100644 --- a/src/mongo/db/commands/count_cmd.cpp +++ b/src/mongo/db/commands/count_cmd.cpp @@ -112,11 +112,11 @@ public: BSONObjBuilder* out) const override { std::string dbname = opMsgRequest.getDatabase().toString(); const BSONObj& cmdObj = opMsgRequest.body; - // Acquire locks and resolve possible UUID. The RAII object is optional, because in the case - // of a view, the locks need to be released. + // Acquire locks. The RAII object is optional, because in the case of a view, the locks + // need to be released. boost::optional<AutoGetCollectionForReadCommand> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsOrUUID(dbname, cmdObj), + CommandHelpers::parseNsCollectionRequired(dbname, cmdObj), AutoGetCollection::ViewMode::kViewsPermitted); const auto nss = ctx->getNss(); diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 90c98b5f70f..3535120348b 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -117,11 +117,11 @@ public: BSONObjBuilder* out) const override { std::string dbname = request.getDatabase().toString(); const BSONObj& cmdObj = request.body; - // Acquire locks and resolve possible UUID. The RAII object is optional, because in the case - // of a view, the locks need to be released. + // Acquire locks. The RAII object is optional, because in the case of a view, the locks + // need to be released. boost::optional<AutoGetCollectionForReadCommand> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsOrUUID(dbname, cmdObj), + CommandHelpers::parseNsCollectionRequired(dbname, cmdObj), AutoGetCollection::ViewMode::kViewsPermitted); const auto nss = ctx->getNss(); diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 63f3c2cd17b..a47959978bc 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -135,11 +135,11 @@ public: BSONObjBuilder* out) const override { std::string dbname = request.getDatabase().toString(); const BSONObj& cmdObj = request.body; - // Acquire locks and resolve possible UUID. The RAII object is optional, because in the case - // of a view, the locks need to be released. + // Acquire locks. The RAII object is optional, because in the case of a view, the locks + // need to be released. boost::optional<AutoGetCollectionForReadCommand> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsOrUUID(dbname, cmdObj), + CommandHelpers::parseNsCollectionRequired(dbname, cmdObj), AutoGetCollection::ViewMode::kViewsPermitted); const auto nss = ctx->getNss(); diff --git a/src/mongo/idl/idl_parser.cpp b/src/mongo/idl/idl_parser.cpp index 46a0c16916e..bb317567fb3 100644 --- a/src/mongo/idl/idl_parser.cpp +++ b/src/mongo/idl/idl_parser.cpp @@ -227,6 +227,12 @@ void IDLParserErrorContext::throwBadEnumValue(StringData enumValue) const { NamespaceString IDLParserErrorContext::parseNSCollectionRequired(StringData dbName, const BSONElement& element) { + const bool isUUID = (element.canonicalType() == canonicalizeBSONType(mongo::BinData) && + element.binDataType() == BinDataType::newUUID); + uassert(ErrorCodes::BadValue, + str::stream() << "Collection name must be provided. UUID is not valid in this " + << "context", + !isUUID); uassert(ErrorCodes::BadValue, str::stream() << "collection name has invalid type " << typeName(element.type()), element.canonicalType() == canonicalizeBSONType(mongo::String)); |