diff options
author | David Storch <david.storch@10gen.com> | 2014-03-20 15:17:23 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2014-03-21 11:47:25 -0400 |
commit | 926d45b2cd43cf255f0994b9da8e518bc381b794 (patch) | |
tree | 9be666664355c49545720f3d6563f98c418d5931 /src/mongo/db/matcher/expression_parser_tree_test.cpp | |
parent | 7ab2c849633e2162f0b5139f842a1a03731f19b2 (diff) | |
download | mongo-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.cpp | 43 |
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" ); |