mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibSQL: Report a syntax error for unsupported LIMIT clause syntax
Rather than aborting when a LIMIT clause of the form 'LIMIT expr, expr' is encountered, fail the parser with a syntax error. This will be nicer for the user and fixes the following fuzzer bug: https://crbug.com/oss-fuzz/34837
This commit is contained in:
parent
0ff09d4f74
commit
a870eac0eb
Notes:
sideshowbarker
2024-07-18 16:58:18 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/a870eac0eb5 Pull-request: https://github.com/SerenityOS/serenity/pull/7720
2 changed files with 3 additions and 2 deletions
|
@ -547,6 +547,7 @@ TEST_CASE(select)
|
|||
EXPECT(parse("SELECT * FROM table LIMIT 12").is_error());
|
||||
EXPECT(parse("SELECT * FROM table LIMIT 12 OFFSET;").is_error());
|
||||
EXPECT(parse("SELECT * FROM table LIMIT 12 OFFSET 15").is_error());
|
||||
EXPECT(parse("SELECT * FROM table LIMIT 15, 16;").is_error());
|
||||
|
||||
struct Type {
|
||||
SQL::ResultType type;
|
||||
|
|
|
@ -321,11 +321,11 @@ NonnullRefPtr<Select> Parser::parse_select_statement(RefPtr<CommonTableExpressio
|
|||
RefPtr<Expression> offset_expression;
|
||||
if (consume_if(TokenType::Offset)) {
|
||||
offset_expression = parse_expression();
|
||||
} else {
|
||||
} else if (consume_if(TokenType::Comma)) {
|
||||
// Note: The limit clause may instead be defined as "offset-expression, limit-expression", effectively reversing the
|
||||
// order of the expressions. SQLite notes "this is counter-intuitive" and "to avoid confusion, programmers are strongly
|
||||
// encouraged to ... avoid using a LIMIT clause with a comma-separated offset."
|
||||
VERIFY(!consume_if(TokenType::Comma));
|
||||
syntax_error("LIMIT clauses of the form 'LIMIT <expr>, <expr>' are not supported");
|
||||
}
|
||||
|
||||
limit_clause = create_ast_node<LimitClause>(move(limit_expression), move(offset_expression));
|
||||
|
|
Loading…
Reference in a new issue