]> git.kaiwu.me - njs.git/commit
XML: fix off-by-one in namespace prefix list parsing
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 13 Aug 2026 03:58:26 +0000 (20:58 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 20 Aug 2026 18:32:21 +0000 (11:32 -0700)
commit1308b320821aa209a7985cc8f52c09a515130ba6
tree92d1d71b68eb36c41790f71d3939f4dd8e835866
parent6898f7c9f844ca30af2aed9e8b1fe10f393644a5
XML: fix off-by-one in namespace prefix list parsing

njs_xml_parse_ns_list() allocated exactly size pointers, but the
terminating NULL was stored at the index equal to the number of parsed
tokens.  When the token count matched the current capacity, the
terminator was written one pointer past the allocation.

The growing loop is replaced with a single allocation holding the array
of pointers followed by the writable copy of the list, the number of
tokens is counted beforehand.

The list is split on any XML whitespace character, empty tokens are not
produced.

Also, fixed potential in place modification of QuickJS string value.

Reported by Vladimir Vulnerability Research Tech Lead @ Cyera, evilgensec
external/njs_xml_module.c
external/qjs_xml_module.c
test/xml/xml.t.mjs