summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_parser_tree_test.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2014-03-20 15:17:23 -0400
committerDavid Storch <david.storch@10gen.com>2014-03-21 11:47:25 -0400
commit926d45b2cd43cf255f0994b9da8e518bc381b794 (patch)
tree9be666664355c49545720f3d6563f98c418d5931 /src/mongo/db/matcher/expression_parser_tree_test.cpp
parent7ab2c849633e2162f0b5139f842a1a03731f19b2 (diff)
downloadmongo-926d45b2cd43cf255f0994b9da8e518bc381b794.tar.gz
SERVER-10026 limit tree depth allowed by the match expression parser
Diffstat (limited to 'src/mongo/db/matcher/expression_parser_tree_test.cpp')
-rw-r--r--src/mongo/db/matcher/expression_parser_tree_test.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_parser_tree_test.cpp b/src/mongo/db/matcher/expression_parser_tree_test.cpp
index 7257353e2ec..ee0507ad274 100644
--- a/src/mongo/db/matcher/expression_parser_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_tree_test.cpp
@@ -100,6 +100,49 @@ namespace mongo {
ASSERT( !result.getValue()->matchesBSON( BSON( "x" << 8 ) ) );
}
+ TEST( MatchExpressionParserTreeTest, MaximumTreeDepth ) {
+ // This match tree is about 60 levels deep, which exceeds
+ // the maximum allowed depth.
+ BSONObj query = fromjson(
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2},"
+ "{$and: [{a: 3}, {$or: [{b: 2}, {b: 4}]}]}"
+ "]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]"
+ "}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}"
+ "]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]});"
+ );
+
+ StatusWithMatchExpression result = MatchExpressionParser::parse( query );
+ ASSERT_FALSE( result.isOK() );
+ }
+
TEST( MatchExpressionParserLeafTest, NotRegex1 ) {
BSONObjBuilder b;
b.appendRegex( "$not", "abc", "i" );