summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/field_path.cpp
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2017-03-21 15:49:49 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2017-03-21 16:02:49 -0400
commitba8c4a2cb599861bcd92446926b72bb17eb5df6b (patch)
tree5ff4826e0b5d581530579d93a416c6f365c9b2f8 /src/mongo/db/pipeline/field_path.cpp
parent19abe0c2dacef784aad78b89d6c6111109fbca88 (diff)
downloadmongo-ba8c4a2cb599861bcd92446926b72bb17eb5df6b.tar.gz
SERVER-8433 prohibit constructing FieldPaths that exceed the depth limit
Diffstat (limited to 'src/mongo/db/pipeline/field_path.cpp')
-rw-r--r--src/mongo/db/pipeline/field_path.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/field_path.cpp b/src/mongo/db/pipeline/field_path.cpp
index b54fbe88b2c..eb20d109861 100644
--- a/src/mongo/db/pipeline/field_path.cpp
+++ b/src/mongo/db/pipeline/field_path.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/pipeline/field_path.h"
#include "mongo/base/string_data.h"
+#include "mongo/bson/bson_depth.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -61,8 +62,12 @@ FieldPath::FieldPath(std::string inputPath)
_fieldPathDotPosition.push_back(_fieldPath.size());
- // Validate fields.
- for (size_t i = 0; i < getPathLength(); ++i) {
+ // Validate the path length and the fields.
+ const auto pathLength = getPathLength();
+ uassert(ErrorCodes::Overflow,
+ "FieldPath is too long",
+ pathLength <= BSONDepth::getMaxAllowableDepth());
+ for (size_t i = 0; i < pathLength; ++i) {
uassertValidFieldName(getFieldName(i));
}
}