]> git.kaiwu.me - njs.git/commit
Regex: fix decoding of named capture indexes
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 4 Sep 2026 01:48:11 +0000 (18:48 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 4 Sep 2026 21:53:08 +0000 (14:53 -0700)
commitbe7faf3dc64e72e1a77e0e28dca2d81abefaaea0
treeaa3b1d139a90a1b9704c5fa2de2257a4eb0cf61f
parent8f5a628bf59feffe25385cf93097eab211f75bad
Regex: fix decoding of named capture indexes

Previously, PCRE name-table capture indexes were decoded through plain char.
On signed-char targets, bytes with the high bit set were sign-extended and
produced a wild or incorrect capture index used to read a match array.

The fix is to decode unsigned bytes through a checked output parameter and to
validate every named capture index against the compiled capture count.

The issue was introduced in 9496944a (0.3.2).

This closes #1088 issue on GitHub.
external/njs_regex.c
src/njs_regex.h
src/njs_regexp.c
src/test/njs_unit_test.c