mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:15:09 +00:00
LibSQL: Limit the number of nested subqueries
SQLite hasn't documented a limit on https://www.sqlite.org/limits.html for the maximum number of nested subqueries. However, its parser is generated with Yacc and has an internal limit of 100 for general nested statements. Fixes https://crbug.com/oss-fuzz/35022.
This commit is contained in:
parent
4e974e6d60
commit
c7cd81bce8
3 changed files with 15 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Parser.h"
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
|
||||
namespace SQL {
|
||||
|
@ -946,6 +947,11 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
|
|||
|
||||
NonnullRefPtr<TableOrSubquery> Parser::parse_table_or_subquery()
|
||||
{
|
||||
if (++m_parser_state.m_current_subquery_depth > Limits::maximum_subquery_depth)
|
||||
syntax_error(String::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
|
||||
|
||||
ScopeGuard guard([&]() { --m_parser_state.m_current_subquery_depth; });
|
||||
|
||||
// https://sqlite.org/syntax/table-or-subquery.html
|
||||
if (match(TokenType::Identifier)) {
|
||||
String schema_name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue