mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Limit the depth of recursion for valid JSON in the JSON1 extension in order
to avoid using excess stack space in the recursive descent parser. Fix for ticket [981329adeef51011052667a9]. FossilOrigin-Name: 1f68c184596912d742b50b1ca38252a9e783aacf121619a27b17a7ae9f6df041
This commit is contained in:
@ -688,5 +688,29 @@ do_execsql_test json-10.95 {
|
||||
SELECT json_valid('" \~ "');
|
||||
} {0}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# 2017-04-11. https://www.sqlite.org/src/info/981329adeef51011
|
||||
# Stack overflow on deeply nested JSON.
|
||||
#
|
||||
# The following tests confirm that deeply nested JSON is considered invalid.
|
||||
#
|
||||
do_execsql_test json-11.0 {
|
||||
/* Shallow enough to be parsed */
|
||||
SELECT json_valid(printf('%.2000c0%.2000c','[',']'));
|
||||
} {1}
|
||||
do_execsql_test json-11.1 {
|
||||
/* Too deep by one */
|
||||
SELECT json_valid(printf('%.2001c0%.2001c','[',']'));
|
||||
} {0}
|
||||
do_execsql_test json-11.2 {
|
||||
/* Shallow enough to be parsed { */
|
||||
SELECT json_valid(replace(printf('%.2000c0%.2000c','[','}'),'[','{"a":'));
|
||||
/* } */
|
||||
} {1}
|
||||
do_execsql_test json-11.3 {
|
||||
/* Too deep by one { */
|
||||
SELECT json_valid(replace(printf('%.2001c0%.2001c','[','}'),'[','{"a":'));
|
||||
/* } */
|
||||
} {0}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user