ngx_http_variable_document_root() can pass an empty string (len == 0,
data from ngx_pnalloc(pool, 0)) to ngx_get_full_name() when root
evaluates to an empty value. ngx_test_full_name() read data[0]
unconditionally, so whether the empty root counted as absolute depended
on uninitialized pool memory. Two evaluations of $document_root in one
script (for example in "if (-f $document_root/file)") could return
different lengths, which fails the script copy check with "no buffer
space in script copy" and a 500 response.
An empty name is now never absolute.
Closes: https://github.com/nginx/nginx/issues/1836
#if (NGX_WIN32)
u_char c0, c1;
+ if (name->len == 0) {
+ return NGX_DECLINED;
+ }
+
c0 = name->data[0];
if (name->len < 2) {
#else
- if (name->data[0] == '/') {
+ if (name->len > 0 && name->data[0] == '/') {
return NGX_OK;
}