summaryrefslogtreecommitdiff
path: root/src/mongo/db/namespace_string-inl.h
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2013-12-06 15:44:02 -0500
committerRandolph Tan <randolph@10gen.com>2013-12-09 14:52:48 -0500
commit5a741123578072e0439f8b3b837f43643b809e0b (patch)
tree2a870cc65f505c21d1d877b3c555808ed19c8765 /src/mongo/db/namespace_string-inl.h
parent1df18f9530aec174f384d5f4ff5efda8218ecd32 (diff)
downloadmongo-5a741123578072e0439f8b3b837f43643b809e0b.tar.gz
SERVER-11968 Write commands allow illegal collection names
Diffstat (limited to 'src/mongo/db/namespace_string-inl.h')
-rw-r--r--src/mongo/db/namespace_string-inl.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/namespace_string-inl.h b/src/mongo/db/namespace_string-inl.h
index 5a03f6d9930..597d9a93159 100644
--- a/src/mongo/db/namespace_string-inl.h
+++ b/src/mongo/db/namespace_string-inl.h
@@ -99,8 +99,18 @@ namespace mongo {
if (coll.empty())
return false;
- return coll.find('$') == std::string::npos;
+ for (StringData::const_iterator iter = coll.begin(), end = coll.end();
+ iter != end; ++iter) {
+ switch (*iter) {
+ case '\0':
+ case '$':
+ return false;
+ default:
+ continue;
+ }
+ }
+ return true;
}
inline NamespaceString::NamespaceString() : _ns(), _dotIndex(0) {}
@@ -126,7 +136,8 @@ namespace mongo {
_dotIndex = dbName.size();
dassert(it == _ns.end());
dassert(_ns[_dotIndex] == '.');
- dassert(_ns.find('\0') == std::string::npos);
+ uassert(17295, "namespaces cannot have embedded null characters",
+ _ns.find('\0') == std::string::npos);
}
inline int nsDBHash( const std::string& ns ) {