]> git.kaiwu.me - nginx.git/commitdiff
Cache: handling of cache files with long headers.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 12 Dec 2011 10:47:48 +0000 (10:47 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 12 Dec 2011 10:47:48 +0000 (10:47 +0000)
There are two possible situations which can lead to this: response was
cached with bigger proxy_buffer_size value (and nginx was restared since
then, i.e. shared memory zone content was lost), or due to the race in
the cache update code (see [1]) we've end up with fcn->body_start from
a different response stored in shared memory zone.

[1] http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001287.html

src/http/ngx_http_file_cache.c

index 6a363220d1733c477e906202e5abf9e48cc4e17b..cb329aa9b3d06ee0e7de542fdd0bcf402857bb6e 100644 (file)
@@ -386,6 +386,13 @@ ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c)
         return NGX_DECLINED;
     }
 
+    if (h->body_start > c->body_start) {
+        ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
+                      "cache file \"%s\" has too long header",
+                      c->file.name.data);
+        return NGX_DECLINED;
+    }
+
     c->buf->last += n;
 
     c->valid_sec = h->valid_sec;