]> git.kaiwu.me - nginx.git/commitdiff
fix segfault if cache key is larger than upstream buffer size
authorIgor Sysoev <igor@sysoev.ru>
Tue, 19 Jul 2011 11:24:16 +0000 (11:24 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 19 Jul 2011 11:24:16 +0000 (11:24 +0000)
patch by Lanshun Zhou

src/http/ngx_http_upstream.c

index f9f09cb34930eb106d069edb60909a55f7d40647..ad5b449ec5915a1b5e772942f4204997cd0c7149 100644 (file)
@@ -661,6 +661,15 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
 
         ngx_http_file_cache_create_key(r);
 
+        if (r->cache->header_start >= u->conf->buffer_size) {
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+                "cache key too large, increase upstream buffer size %uz",
+                u->conf->buffer_size);
+
+            r->cache = NULL;
+            return NGX_DECLINED;
+        }
+
         switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) {
 
         case NGX_ERROR: