From ed0b19cdd4a9118cf8795ba2cf0a56684624bb41 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Fri, 4 Aug 2017 19:37:37 +0300 Subject: 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". --- src/http/ngx_http_cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/http/ngx_http_cache.h') diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h index cd0b4bbf8..d010a4ef0 100644 --- a/src/http/ngx_http_cache.h +++ b/src/http/ngx_http_cache.h @@ -80,6 +80,7 @@ struct ngx_http_cache_s { 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; -- cgit From dc1b14126e0a7a45018d95b149ebdb29985f18f1 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Wed, 9 Sep 2020 19:26:27 +0300 Subject: Cache: keep c->body_start when Vary changes (ticket #2029). If the variant hash doesn't match one we used as a secondary cache key, we switch back to the original key. In this case, c->body_start was kept updated from an existing cache node overwriting the new response value. After file cache update, it led to discrepancy between a cache node and cache file seen as critical errors "file cache .. has too long header". --- src/http/ngx_http_cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/http/ngx_http_cache.h') diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h index d010a4ef0..bb936c5fe 100644 --- a/src/http/ngx_http_cache.h +++ b/src/http/ngx_http_cache.h @@ -117,6 +117,7 @@ struct ngx_http_cache_s { unsigned purged:1; unsigned reading:1; unsigned secondary:1; + unsigned update_variant:1; unsigned background:1; unsigned stale_updating:1; -- cgit