From: Roman Arutyunyan Date: Thu, 5 Nov 2026 14:50:48 +0000 (+0400) Subject: Try files: fix uri formating in case of script underwrite X-Git-Tag: release-1.31.9~1 X-Git-Url: https://git.kaiwu.me/virtual_hosts.html?a=commitdiff_plain;h=d1ffe6fa89fee120411dd4d37206c1482d869480;p=nginx.git Try files: fix uri formating in case of script underwrite Previously, if try_files was used with alias, and the script produced a string smaller than the predicted size, then an integer underflow could happen which resulted in buffer overrun. Fix is to recalculate the length after running the script. A similar length recalculation exists in ngx_http_index_module. It was added by 25f920eca when fixing script overruns. Reported by Marc Luchian & Liviu-Alexandru Bud. --- diff --git a/src/http/modules/ngx_http_try_files_module.c b/src/http/modules/ngx_http_try_files_module.c index bbdab8598..909260285 100644 --- a/src/http/modules/ngx_http_try_files_module.c +++ b/src/http/modules/ngx_http_try_files_module.c @@ -186,6 +186,7 @@ ngx_http_try_files_handler(ngx_http_request_t *r) return NGX_ERROR; } + len = e.pos - name + 1; path.len = e.pos - path.data; *e.pos = '\0';