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
return NULL;
}
+ path->data[path->len - reserved] = '\0';
+
if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, path)
!= NGX_OK)
{