[nginx] Cache: reset c->body_start when reading a variant on Vary mismatch.
Sergey Kandaurov
pluknet at nginx.com
Fri Sep 11 19:16:43 UTC 2020
details: https://hg.nginx.org/nginx/rev/847fd35f94de
branches:
changeset: 7704:847fd35f94de
user: Sergey Kandaurov <pluknet at nginx.com>
date: Fri Aug 04 19:37:37 2017 +0300
description:
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".
diffstat:
src/http/ngx_http_cache.h | 1 +
src/http/ngx_http_file_cache.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diffs (32 lines):
diff -r da5e3f5b1673 -r 847fd35f94de src/http/ngx_http_cache.h
--- 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 @@ 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;
diff -r da5e3f5b1673 -r 847fd35f94de src/http/ngx_http_file_cache.c
--- 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 @@ ngx_http_file_cache_open(ngx_http_reques
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 @@ ngx_http_file_cache_reopen(ngx_http_requ
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);
More information about the nginx-devel
mailing list