simdjson_php icon indicating copy to clipboard operation
simdjson_php copied to clipboard

simdjson_is_valid fails silently when json has depth exceeding 1024

Open TysonAndre opened this issue 2 years ago • 0 comments

With display_errors=stderr and error_reporting=E_ALL, there is still no reported error. simdjson should probably check the error result for errors specifically caused by recursion depth and emit a notice

php > var_export(simdjson_is_valid(str_repeat('[', 1000) . str_repeat(']', 1000)));
true
php > var_export(simdjson_is_valid(str_repeat('[', 1050) . str_repeat(']', 1050)));
false
  1. This should emit a warning or an error instead?
  2. The depth limit should be configurable
  3. Note that struct open_container in the simdjson implementation means that 8+1 bytes will be used for a given depth limit, so the alternative of setting depth to json_length / 2 may (1) overflow size_t on 32-bit implementation, and (2) run out of memory

TysonAndre avatar Aug 07 '22 19:08 TysonAndre