From: Aaron Queen Date: Mon, 12 Oct 2026 18:56:37 +0000 (-0600) Subject: Fixed testing unset path bytes for an empty variable root X-Git-Url: https://git.kaiwu.me/%7Bsubstring-before(@doc,%20'.xml')%7D.html?a=commitdiff_plain;h=d59c45e95365fda52d6b568a2c148fe1a0499849;p=nginx.git Fixed testing unset path bytes for an empty variable root ngx_http_map_uri_to_path() runs the root script with the space for the URI reserved after it, then passes the whole buffer to ngx_get_full_name(). When root evaluated to an empty string, the first byte tested by ngx_test_full_name() was in the reserved space, which had not been written yet, so the same request could map to a path relative to the prefix or to a path from the file system root. A NUL byte is now written where the root ends, so an empty root is an empty string and not unset bytes. Closes: https://github.com/nginx/nginx/issues/1836 --- diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 30ae6e0ec..85cf3aea1 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -2029,6 +2029,8 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, return NULL; } + path->data[path->len - reserved] = '\0'; + if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, path) != NGX_OK) {