Browse Source

[core] stat_cache_path_contains_symlink use errh

use log_error() with con->errh
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
2ec70f234a
  1. 2
      src/http-header-glue.c
  2. 8
      src/http_chunk.c
  3. 2
      src/mod_compress.c
  4. 2
      src/mod_ssi.c
  5. 2
      src/response.c
  6. 6
      src/stat_cache.c
  7. 2
      src/stat_cache.h

2
src/http-header-glue.c

@ -447,7 +447,7 @@ void http_response_send_file (server *srv, connection *con, buffer *path) {
}
if (!con->conf.follow_symlink
&& 0 != stat_cache_path_contains_symlink(srv, path)) {
&& 0 != stat_cache_path_contains_symlink(con, path)) {
con->http_status = 403;
if (con->conf.log_request_handling) {

8
src/http_chunk.c

@ -34,9 +34,9 @@ static void http_chunk_append_len(server *srv, connection *con, uintmax_t len) {
chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b));
}
static int http_chunk_append_file_open_fstat(server *srv, connection *con, buffer *fn, struct stat *st) {
static int http_chunk_append_file_open_fstat(connection *con, buffer *fn, struct stat *st) {
if (!con->conf.follow_symlink
&& 0 != stat_cache_path_contains_symlink(srv, fn)) {
&& 0 != stat_cache_path_contains_symlink(con, fn)) {
return -1;
}
@ -89,7 +89,7 @@ static void http_chunk_append_file_fd_range(server *srv, connection *con, buffer
int http_chunk_append_file_range(server *srv, connection *con, buffer *fn, off_t offset, off_t len) {
struct stat st;
const int fd = http_chunk_append_file_open_fstat(srv, con, fn, &st);
const int fd = http_chunk_append_file_open_fstat(con, fn, &st);
if (fd < 0) return -1;
if (-1 == len) {
@ -109,7 +109,7 @@ int http_chunk_append_file_range(server *srv, connection *con, buffer *fn, off_t
int http_chunk_append_file(server *srv, connection *con, buffer *fn) {
struct stat st;
const int fd = http_chunk_append_file_open_fstat(srv, con, fn, &st);
const int fd = http_chunk_append_file_open_fstat(con, fn, &st);
if (fd < 0) return -1;
http_chunk_append_file_fd(srv, con, fn, fd, st.st_size);
return 0;

2
src/mod_compress.c

@ -904,7 +904,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
int compression_type = 0;
if (!con->conf.follow_symlink
&& 0 != stat_cache_path_contains_symlink(srv, con->physical.path)) {
&& 0 != stat_cache_path_contains_symlink(con, con->physical.path)) {
return HANDLER_GO_ON;
}

2
src/mod_ssi.c

@ -608,7 +608,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const
}
if (!con->conf.follow_symlink
&& 0 != stat_cache_path_contains_symlink(srv, p->stat_fn)) {
&& 0 != stat_cache_path_contains_symlink(con, p->stat_fn)) {
break;
}

2
src/response.c

@ -247,7 +247,7 @@ static handler_t http_response_physical_path_check(server *srv, connection *con)
}
if (!con->conf.follow_symlink
&& 0 != stat_cache_path_contains_symlink(srv, con->physical.path)) {
&& 0 != stat_cache_path_contains_symlink(con, con->physical.path)) {
con->http_status = 403;
if (con->conf.log_request_handling) {

6
src/stat_cache.c

@ -1000,7 +1000,7 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
return HANDLER_GO_ON;
}
int stat_cache_path_contains_symlink(server *srv, buffer *name) {
int stat_cache_path_contains_symlink(connection *con, buffer *name) {
/* caller should check for symlinks only if we should block symlinks. */
/* catch the obvious symlinks
@ -1036,8 +1036,8 @@ int stat_cache_path_contains_symlink(server *srv, buffer *name) {
if (S_ISLNK(st.st_mode)) return 1;
}
else {
log_error_write(srv, __FILE__, __LINE__, "sss",
"lstat failed for:", buf, strerror(errno));
log_perror(con->errh, __FILE__, __LINE__,
"lstat failed for: %s", buf);
return -1;
}
} while ((s_cur = strrchr(buf, '/')) != buf);

2
src/stat_cache.h

@ -44,7 +44,7 @@ void stat_cache_delete_entry(server *srv, const char *name, size_t len);
void stat_cache_delete_dir(server *srv, const char *name, size_t len);
void stat_cache_invalidate_entry(server *srv, const char *name, size_t len);
handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_cache_entry **sce);
int stat_cache_path_contains_symlink(server *srv, buffer *name);
int stat_cache_path_contains_symlink(connection *con, buffer *name);
int stat_cache_open_rdonly_fstat (buffer *name, struct stat *st, int symlinks);
int stat_cache_trigger_cleanup(server *srv);

Loading…
Cancel
Save