From db4950366803c421c629a49a1c63606b0d1b81d9 Mon Sep 17 00:00:00 2001 From: Hanada Date: Mon, 22 Jun 2026 10:20:05 +0800 Subject: [PATCH] bugfix: avoid truncating Lua context in filters The request context was widened from uint16_t to uint32_t when phase flags grew beyond 16 bits, but the header and body filters continued saving it in a uint16_t old_context variable. Contexts above 0xffff were truncated while running a filter and restored as zero afterward. Use uint32_t for old_context to preserve the complete phase value. --- src/ngx_http_lua_bodyfilterby.c | 2 +- src/ngx_http_lua_headerfilterby.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ngx_http_lua_bodyfilterby.c b/src/ngx_http_lua_bodyfilterby.c index cb5f7eb608..b2a1df2212 100644 --- a/src/ngx_http_lua_bodyfilterby.c +++ b/src/ngx_http_lua_bodyfilterby.c @@ -241,7 +241,7 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ngx_http_lua_loc_conf_t *llcf; ngx_http_lua_ctx_t *ctx; ngx_int_t rc; - uint16_t old_context; + uint32_t old_context; ngx_pool_cleanup_t *cln; ngx_chain_t *out; ngx_chain_t *cl, *ln; diff --git a/src/ngx_http_lua_headerfilterby.c b/src/ngx_http_lua_headerfilterby.c index d41c055ef5..6413cd2c2c 100644 --- a/src/ngx_http_lua_headerfilterby.c +++ b/src/ngx_http_lua_headerfilterby.c @@ -240,7 +240,7 @@ ngx_http_lua_header_filter(ngx_http_request_t *r) ngx_http_lua_ctx_t *ctx; ngx_int_t rc; ngx_pool_cleanup_t *cln; - uint16_t old_context; + uint32_t old_context; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "lua header filter for user lua code, uri \"%V\"", &r->uri);