Tolerate '\0' in URI when mapping URI to path.

If a rewritten URI has the null character, only a part of URI was
copied to a memory buffer allocated for path.  In some setups this
could be exploited to expose uninitialized memory via the Location
header.
This commit is contained in:
Ruslan Ermilov 2019-12-16 15:19:01 +03:00
parent af8ea176a7
commit a5895eb502

View File

@ -1843,7 +1843,8 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
}
}
last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
last = ngx_copy(last, r->uri.data + alias, r->uri.len - alias);
*last = '\0';
return last;
}