comparison src/http/ngx_http_file_cache.c @ 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 ccb5ff87ab3e
children 3781de64e747
comparison
equal deleted inserted replaced
7703:da5e3f5b1673 7704:847fd35f94de
292 292
293 cln->handler = ngx_http_file_cache_cleanup; 293 cln->handler = ngx_http_file_cache_cleanup;
294 cln->data = c; 294 cln->data = c;
295 } 295 }
296 296
297 c->buffer_size = c->body_start;
298
297 rc = ngx_http_file_cache_exists(cache, c); 299 rc = ngx_http_file_cache_exists(cache, c);
298 300
299 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 301 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
300 "http file cache exists: %i e:%d", rc, c->exists); 302 "http file cache exists: %i e:%d", rc, c->exists);
301 303
1228 1230
1229 ngx_shmtx_unlock(&cache->shpool->mutex); 1231 ngx_shmtx_unlock(&cache->shpool->mutex);
1230 1232
1231 c->secondary = 1; 1233 c->secondary = 1;
1232 c->file.name.len = 0; 1234 c->file.name.len = 0;
1233 c->body_start = c->buf->end - c->buf->start; 1235 c->body_start = c->buffer_size;
1234 1236
1235 ngx_memcpy(c->key, c->variant, NGX_HTTP_CACHE_KEY_LEN); 1237 ngx_memcpy(c->key, c->variant, NGX_HTTP_CACHE_KEY_LEN);
1236 1238
1237 return ngx_http_file_cache_open(r); 1239 return ngx_http_file_cache_open(r);
1238 } 1240 }