mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:45:06 +00:00
LibSQL: Limit the allowed depth of an expression tree
According to the definition at https://sqlite.org/lang_expr.html, SQL expressions could be infinitely deep. For practicality, SQLite enforces a maxiumum expression tree depth of 1000. Apply the same limit in LibSQL to avoid stack overflow in the expression parser. Fixes https://crbug.com/oss-fuzz/34859.
This commit is contained in:
parent
3d9bcb860e
commit
f8f36effc9
3 changed files with 19 additions and 0 deletions
|
@ -602,3 +602,10 @@ TEST_CASE(in_selection_expression)
|
|||
validate("15 IN (SELECT * FROM table)", false);
|
||||
validate("15 NOT IN (SELECT * FROM table)", true);
|
||||
}
|
||||
|
||||
TEST_CASE(stack_limit)
|
||||
{
|
||||
auto too_deep_expression = String::formatted("{:+^{}}1", "", SQL::Limits::maximum_expression_tree_depth);
|
||||
EXPECT(!parse(too_deep_expression.substring_view(1)).is_error());
|
||||
EXPECT(parse(too_deep_expression).is_error());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue