Add missing bounds check in ngx_{http,stream}_compile_complex_value()

Complex value compilation scans strings for $1..$9 capture references.
Check that a byte after '$' is present before testing it, matching
ngx_str_t length semantics and avoiding reliance on NUL termination.

Apply the same check to both HTTP and stream implementations.
This commit is contained in:
Feng Wu authored and VadimZhestikov committed 2026-06-25 09:15:44 -07:00
1 parent 2d71bdcf8b
commit 42f8df65b6
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -151,7 +151,9 @@ ngx_stream_compile_complex_value(ngx_stream_compile_complex_value_t *ccv)
for (i = 0; i < v->len; i++) {
if (v->data[i] == '$') {
if (v->data[i + 1] >= '1' && v->data[i + 1] <= '9') {
if (i + 1 < v->len
&& v->data[i + 1] >= '1' && v->data[i + 1] <= '9')
{
nc++;
} else {