Mercurial > hg > nginx
changeset 7704:847fd35f94de
Cache: reset c->body_start when reading a variant on Vary mismatch.
Previously, a variant not present in shared memory and stored on disk using a
secondary key was read using c->body_start from a variant stored with a main
key. This could result in critical errors "cache file .. has too long header".
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 04 Aug 2017 19:37:37 +0300 |
parents | da5e3f5b1673 |
children | 3781de64e747 |
files | src/http/ngx_http_cache.h src/http/ngx_http_file_cache.c |
diffstat | 2 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_cache.h Wed Sep 02 23:13:36 2020 +0300 +++ b/src/http/ngx_http_cache.h Fri Aug 04 19:37:37 2017 +0300 @@ -80,6 +80,7 @@ ngx_str_t vary; u_char variant[NGX_HTTP_CACHE_KEY_LEN]; + size_t buffer_size; size_t header_start; size_t body_start; off_t length;
--- a/src/http/ngx_http_file_cache.c Wed Sep 02 23:13:36 2020 +0300 +++ b/src/http/ngx_http_file_cache.c Fri Aug 04 19:37:37 2017 +0300 @@ -294,6 +294,8 @@ cln->data = c; } + c->buffer_size = c->body_start; + rc = ngx_http_file_cache_exists(cache, c); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, @@ -1230,7 +1232,7 @@ c->secondary = 1; c->file.name.len = 0; - c->body_start = c->buf->end - c->buf->start; + c->body_start = c->buffer_size; ngx_memcpy(c->key, c->variant, NGX_HTTP_CACHE_KEY_LEN);