From 2ec70f234a03ed9f580a09d2f4cd04e8c288a5d9 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 20 Nov 2019 01:17:06 -0500 Subject: [PATCH] [core] stat_cache_path_contains_symlink use errh use log_error() with con->errh --- src/http-header-glue.c | 2 +- src/http_chunk.c | 8 ++++---- src/mod_compress.c | 2 +- src/mod_ssi.c | 2 +- src/response.c | 2 +- src/stat_cache.c | 6 +++--- src/stat_cache.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/http-header-glue.c b/src/http-header-glue.c index fa9ff8c5..62c8d62a 100644 --- a/src/http-header-glue.c +++ b/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) { diff --git a/src/http_chunk.c b/src/http_chunk.c index 87af3e7c..22c6950c 100644 --- a/src/http_chunk.c +++ b/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; diff --git a/src/mod_compress.c b/src/mod_compress.c index 4aa62351..a932667e 100644 --- a/src/mod_compress.c +++ b/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; } diff --git a/src/mod_ssi.c b/src/mod_ssi.c index 8ba4342f..3425cb7b 100644 --- a/src/mod_ssi.c +++ b/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; } diff --git a/src/response.c b/src/response.c index 84a24b7d..f9069b23 100644 --- a/src/response.c +++ b/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) { diff --git a/src/stat_cache.c b/src/stat_cache.c index 7728e8ab..2558fc09 100644 --- a/src/stat_cache.c +++ b/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); diff --git a/src/stat_cache.h b/src/stat_cache.h index da0aafba..9edfcc69 100644 --- a/src/stat_cache.h +++ b/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);