]> git.kaiwu.me - njs.git/commit
Fixed heap-use-after-free in JSON.parse().
authorAlexander Borisov <alexander.borisov@nginx.com>
Tue, 6 Oct 2020 16:53:26 +0000 (19:53 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Tue, 6 Oct 2020 16:53:26 +0000 (19:53 +0300)
commit9ab425eac2b6c7eb3a932c8e6934e9992435e328
treecff6d3d8f99b16a1a68e350503802d52f3ca6744
parentfbab642a1ee6767c2fe9c1ea9e54073fae2272a2
Fixed heap-use-after-free in JSON.parse().

This correctly fixes the issues addressed in 1405:9beb9ea093b5.
The initial fix wrongly assumed that the "value" pointer is still valid when
njs_is_fast_array(&state->value) is true and the pointer can be used for
the fast path.  This is not the case when the array object is resized.

Moreover, the fast path branch may be completely eliminated because
JSON.parse() with the replacer function is relatively slow by itself.

This closes #323, #324, #325 issues on GitHub.
src/njs_json.c
src/test/njs_unit_test.c