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

src/http/ngx_http_upstream.c

index e8d87738fdd8c1d0589413d23ee7d412c5e8f881..62f1669c70bd368713423fd054da770fec52e8bc 100644 (file)
@@ -666,6 +666,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;
+        }
+
         u->cacheable = 1;
 
         c = r->cache;