[core] add xsendfile* check if xdocroot is NULL

This commit is contained in:
Glenn Strauss 2019-11-07 00:15:17 -05:00
parent 16665ae5f4
commit 858352f6e8
2 changed files with 5 additions and 5 deletions

View File

@ -633,7 +633,7 @@ static void http_response_xsendfile (server *srv, connection *con, buffer *path,
* - xdocroot should have trailing slash appended at config time
* - con->conf.force_lowercase_filenames is not a server-wide setting,
* and so can not be definitively applied to xdocroot at config time*/
if (xdocroot->used) {
if (xdocroot) {
size_t i, xlen = buffer_string_length(path);
for (i = 0; i < xdocroot->used; ++i) {
data_string *ds = (data_string *)xdocroot->data[i];
@ -645,7 +645,7 @@ static void http_response_xsendfile (server *srv, connection *con, buffer *path,
break;
}
}
if (i == xdocroot->used) {
if (i == xdocroot->used && 0 != i) {
log_error_write(srv, __FILE__, __LINE__, "SBs",
"X-Sendfile (", path,
") not under configured x-sendfile-docroot(s)");
@ -707,7 +707,7 @@ static void http_response_xsendfile2(server *srv, connection *con, const buffer
if (con->conf.force_lowercase_filenames) {
buffer_to_lower(b);
}
if (xdocroot->used) {
if (xdocroot) {
size_t i, xlen = buffer_string_length(b);
for (i = 0; i < xdocroot->used; ++i) {
data_string *ds = (data_string *)xdocroot->data[i];
@ -719,7 +719,7 @@ static void http_response_xsendfile2(server *srv, connection *con, const buffer
break;
}
}
if (i == xdocroot->used) {
if (i == xdocroot->used && 0 != i) {
log_error_write(srv, __FILE__, __LINE__, "SBs",
"X-Sendfile2 (", b,
") not under configured x-sendfile-docroot(s)");

View File

@ -32,7 +32,7 @@ typedef struct http_response_opts_t {
int authorizer;
unsigned short local_redir;
unsigned short xsendfile_allow;
array *xsendfile_docroot;
const array *xsendfile_docroot;
void *pdata;
handler_t(*parse)(server *, connection *, struct http_response_opts_t *, buffer *, size_t);
handler_t(*headers)(server *, connection *, struct http_response_opts_t *);