diff src/http/ngx_http_cache.c @ 189:c966c09be66b

nginx-0.0.1-2003-11-18-19:49:00 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 18 Nov 2003 16:49:00 +0000
parents c1f3a3c7c5db
children 02a715e85df1
line wrap: on
line diff
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -107,6 +107,13 @@ int ngx_http_cache_open_file(ngx_http_re
     ctx->date = h->date;
     ctx->length = h->length;
 
+    if (h->key_len > (size_t) (ctx->buf->last - ctx->buf->pos)) {
+        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+                      "cache file \"%s\" is probably invalid",
+                      ctx->file.name.data);
+        return NGX_DECLINED;
+    }
+
     if (h->key_len != ctx->key.len
         || ngx_strncmp(h->key, ctx->key.data, h->key_len) != 0)
     {