]> git.kaiwu.me - njs.git/commit
Buffer: fix type confusion in concat() with element getters
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 12 Jun 2026 01:31:27 +0000 (18:31 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 16 Jun 2026 23:22:57 +0000 (16:22 -0700)
commit943a9f358feda2e9b28445a781464a291d0b763e
treec3e0548c3186e9ce3d86ebc9777767891a07efaf
parente07124084a246ed40d2221da1e2f3e624e93588f
Buffer: fix type confusion in concat() with element getters

njs_buffer_concat() validated each list element as a typed array in the
length pass, then re-read the same elements with njs_value_property_i64()
in the copy pass and cast them with njs_typed_array() without rechecking.
For a non-fast array with an accessor element, a getter returning a typed
array during validation and a non-typed-array (or a detached buffer)
during the copy yielded a wild pointer and an out-of-bounds read.

Revalidate the type and detached state in the copy pass, matching the
length pass and the QuickJS implementation.
src/njs_buffer.c
test/buffer.t.js