src/http/ngx_http_file_cache.c:214: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned64 by call to `ngx_http_file_cache_exists`.

src/http/ngx_http_file_cache.c:206:11: Call
204.     cache = c->file_cache;
205. 
206.     cln = ngx_pool_cleanup_add(r->pool, 0);
               ^
207.     if (cln == NULL) {
208.         return NGX_ERROR;

src/core/ngx_palloc.c:316:9: Call
  314.     ngx_pool_cleanup_t  *c;
  315. 
  316.     c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t));
               ^
  317.     if (c == NULL) {
  318.         return NULL;

src/core/ngx_palloc.c:131:12: Call
    129. #endif
    130. 
    131.     return ngx_palloc_large(pool, size);
                    ^
    132. }
    133. 

src/core/ngx_palloc.c:220:9: Call
      218.     ngx_pool_large_t  *large;
      219. 
      220.     p = ngx_alloc(size, pool->log);
                   ^
      221.     if (p == NULL) {
      222.         return NULL;

src/os/unix/ngx_alloc.c:17:1: Parameter `log->next->disk_full_time`
        15. 
        16. 
        17. void *
            ^
        18. ngx_alloc(size_t size, ngx_log_t *log)
        19. {

src/http/ngx_http_file_cache.c:214:9: Call
212.     cln->data = c;
213. 
214.     if (ngx_http_file_cache_exists(cache, c) == NGX_ERROR) {
             ^
215.         return NGX_ERROR;
216.     }

src/http/ngx_http_file_cache.c:818:1: Parameter `cache->sh->count`
  816. 
  817. 
  818. static ngx_int_t
       ^
  819. ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
  820. {

src/http/ngx_http_file_cache.c:875:16: Call
  873.         ngx_shmtx_unlock(&cache->shpool->mutex);
  874. 
  875.         (void) ngx_http_file_cache_forced_expire(cache);
                      ^
  876. 
  877.         ngx_shmtx_lock(&cache->shpool->mutex);

src/http/ngx_http_file_cache.c:1700:1: Parameter `cache->sh->count`
    1698. 
    1699. 
    1700. static time_t
          ^
    1701. ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)
    1702. {

src/http/ngx_http_file_cache.c:1750:13: Call
    1748. 
    1749.         if (fcn->count == 0) {
    1750.             ngx_http_file_cache_delete(cache, q, name);
                      ^
    1751.             wait = 0;
    1752.             break;

src/http/ngx_http_file_cache.c:1905:1: <LHS trace>
1903. 
1904. 
1905. static void
      ^
1906. ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
1907.     u_char *name)

src/http/ngx_http_file_cache.c:1905:1: Parameter `cache->sh->count`
      1903. 
      1904. 
      1905. static void
            ^
      1906. ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
      1907.     u_char *name)

src/http/ngx_http_file_cache.c:1951:9: Binary operation: ([0, +oo] - 1):unsigned64 by call to `ngx_http_file_cache_exists` 
      1949.         ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
      1950.         ngx_slab_free_locked(cache->shpool, fcn);
      1951.         cache->sh->count--;
                    ^
      1952.     }
      1953. }

static void
ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
    u_char *name)
{
    u_char                      *p;
    size_t                       len;
    ngx_path_t                  *path;
    ngx_http_file_cache_node_t  *fcn;
    fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);
    if (fcn->exists) {
        cache->sh->size -= fcn->fs_size;
        path = cache->path;
        p = name + path->name.len + 1 + path->len;
        p = ngx_hex_dump(p, (u_char *) &fcn->node.key,
                         sizeof(ngx_rbtree_key_t));
        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);
        p = ngx_hex_dump(p, fcn->key, len);
        *p = '\0';
        fcn->count++;
        fcn->deleting = 1;
        ngx_shmtx_unlock(&cache->shpool->mutex);
        len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;
        ngx_create_hashed_filename(path, name, len);
        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
                       "http file cache expire: \"%s\"", name);
        if (ngx_delete_file(name) == NGX_FILE_ERROR) {
            ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno,
                          ngx_delete_file_n " \"%s\" failed", name);
        }
        ngx_shmtx_lock(&cache->shpool->mutex);
        fcn->count--;
        fcn->deleting = 0;
    }
    if (fcn->count == 0) {
        ngx_queue_remove(q);
        ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
        ngx_slab_free_locked(cache->shpool, fcn);
        cache->sh->count--;
    }
}
['ngx_int_t\nngx_http_file_cache_create(ngx_http_request_t *r)\n{\n    ngx_http_cache_t       *c;\n    ngx_pool_cleanup_t     *cln;\n    ngx_http_file_cache_t  *cache;\n    c = r->cache;\n    cache = c->file_cache;\n    cln = ngx_pool_cleanup_add(r->pool, 0);\n    if (cln == NULL) {\n        return NGX_ERROR;\n    }\n    cln->handler = ngx_http_file_cache_cleanup;\n    cln->data = c;\n    if (ngx_http_file_cache_exists(cache, c) == NGX_ERROR) {\n        return NGX_ERROR;\n    }\n    if (ngx_http_file_cache_name(r, cache->path) != NGX_OK) {\n        return NGX_ERROR;\n    }\n    return NGX_OK;\n}', 'ngx_pool_cleanup_t *\nngx_pool_cleanup_add(ngx_pool_t *p, size_t size)\n{\n    ngx_pool_cleanup_t  *c;\n    c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t));\n    if (c == NULL) {\n        return NULL;\n    }\n    if (size) {\n        c->data = ngx_palloc(p, size);\n        if (c->data == NULL) {\n            return NULL;\n        }\n    } else {\n        c->data = NULL;\n    }\n    c->handler = NULL;\n    c->next = p->cleanup;\n    p->cleanup = c;\n    ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, p->log, 0, "add cleanup: %p", c);\n    return c;\n}', 'void *\nngx_palloc(ngx_pool_t *pool, size_t size)\n{\n#if !(NGX_DEBUG_PALLOC)\n    if (size <= pool->max) {\n        return ngx_palloc_small(pool, size, 1);\n    }\n#endif\n    return ngx_palloc_large(pool, size);\n}', 'static void *\nngx_palloc_large(ngx_pool_t *pool, size_t size)\n{\n    void              *p;\n    ngx_uint_t         n;\n    ngx_pool_large_t  *large;\n    p = ngx_alloc(size, pool->log);\n    if (p == NULL) {\n        return NULL;\n    }\n    n = 0;\n    for (large = pool->large; large; large = large->next) {\n        if (large->alloc == NULL) {\n            large->alloc = p;\n            return p;\n        }\n        if (n++ > 3) {\n            break;\n        }\n    }\n    large = ngx_palloc_small(pool, sizeof(ngx_pool_large_t), 1);\n    if (large == NULL) {\n        ngx_free(p);\n        return NULL;\n    }\n    large->alloc = p;\n    large->next = pool->large;\n    pool->large = large;\n    return p;\n}', 'void *\nngx_alloc(size_t size, ngx_log_t *log)\n{\n    void  *p;\n    p = malloc(size);\n    if (p == NULL) {\n        ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,\n                      "malloc(%uz) failed", size);\n    }\n    ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %p:%uz", p, size);\n    return p;\n}', 'static ngx_int_t\nngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)\n{\n    ngx_int_t                    rc;\n    ngx_http_file_cache_node_t  *fcn;\n    ngx_shmtx_lock(&cache->shpool->mutex);\n    fcn = c->node;\n    if (fcn == NULL) {\n        fcn = ngx_http_file_cache_lookup(cache, c->key);\n    }\n    if (fcn) {\n        ngx_queue_remove(&fcn->queue);\n        if (c->node == NULL) {\n            fcn->uses++;\n            fcn->count++;\n        }\n        if (fcn->error) {\n            if (fcn->valid_sec < ngx_time()) {\n                goto renew;\n            }\n            rc = NGX_OK;\n            goto done;\n        }\n        if (fcn->exists || fcn->uses >= c->min_uses) {\n            c->exists = fcn->exists;\n            if (fcn->body_start) {\n                c->body_start = fcn->body_start;\n            }\n            rc = NGX_OK;\n            goto done;\n        }\n        rc = NGX_AGAIN;\n        goto done;\n    }\n    fcn = ngx_slab_calloc_locked(cache->shpool,\n                                 sizeof(ngx_http_file_cache_node_t));\n    if (fcn == NULL) {\n        ngx_http_file_cache_set_watermark(cache);\n        ngx_shmtx_unlock(&cache->shpool->mutex);\n        (void) ngx_http_file_cache_forced_expire(cache);\n        ngx_shmtx_lock(&cache->shpool->mutex);\n        fcn = ngx_slab_calloc_locked(cache->shpool,\n                                     sizeof(ngx_http_file_cache_node_t));\n        if (fcn == NULL) {\n            ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,\n                          "could not allocate node%s", cache->shpool->log_ctx);\n            rc = NGX_ERROR;\n            goto failed;\n        }\n    }\n    cache->sh->count++;\n    ngx_memcpy((u_char *) &fcn->node.key, c->key, sizeof(ngx_rbtree_key_t));\n    ngx_memcpy(fcn->key, &c->key[sizeof(ngx_rbtree_key_t)],\n               NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t));\n    ngx_rbtree_insert(&cache->sh->rbtree, &fcn->node);\n    fcn->uses = 1;\n    fcn->count = 1;\nrenew:\n    rc = NGX_DECLINED;\n    fcn->valid_msec = 0;\n    fcn->error = 0;\n    fcn->exists = 0;\n    fcn->valid_sec = 0;\n    fcn->uniq = 0;\n    fcn->body_start = 0;\n    fcn->fs_size = 0;\ndone:\n    fcn->expire = ngx_time() + cache->inactive;\n    ngx_queue_insert_head(&cache->sh->queue, &fcn->queue);\n    c->uniq = fcn->uniq;\n    c->error = fcn->error;\n    c->node = fcn;\nfailed:\n    ngx_shmtx_unlock(&cache->shpool->mutex);\n    return rc;\n}', 'static time_t\nngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)\n{\n    u_char                      *name, *p;\n    size_t                       len;\n    time_t                       wait;\n    ngx_uint_t                   tries;\n    ngx_path_t                  *path;\n    ngx_queue_t                 *q, *sentinel;\n    ngx_http_file_cache_node_t  *fcn;\n    u_char                       key[2 * NGX_HTTP_CACHE_KEY_LEN];\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                   "http file cache forced expire");\n    path = cache->path;\n    len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;\n    name = ngx_alloc(len + 1, ngx_cycle->log);\n    if (name == NULL) {\n        return 10;\n    }\n    ngx_memcpy(name, path->name.data, path->name.len);\n    wait = 10;\n    tries = 20;\n    sentinel = NULL;\n    ngx_shmtx_lock(&cache->shpool->mutex);\n    for ( ;; ) {\n        if (ngx_queue_empty(&cache->sh->queue)) {\n            break;\n        }\n        q = ngx_queue_last(&cache->sh->queue);\n        if (q == sentinel) {\n            break;\n        }\n        fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);\n        ngx_log_debug6(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                  "http file cache forced expire: #%d %d %02xd%02xd%02xd%02xd",\n                  fcn->count, fcn->exists,\n                  fcn->key[0], fcn->key[1], fcn->key[2], fcn->key[3]);\n        if (fcn->count == 0) {\n            ngx_http_file_cache_delete(cache, q, name);\n            wait = 0;\n            break;\n        }\n        p = ngx_hex_dump(key, (u_char *) &fcn->node.key,\n                         sizeof(ngx_rbtree_key_t));\n        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);\n        (void) ngx_hex_dump(p, fcn->key, len);\n        ngx_queue_remove(q);\n        fcn->expire = ngx_time() + cache->inactive;\n        ngx_queue_insert_head(&cache->sh->queue, &fcn->queue);\n        ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,\n                      "ignore long locked inactive cache entry %*s, count:%d",\n                      (size_t) 2 * NGX_HTTP_CACHE_KEY_LEN, key, fcn->count);\n        if (sentinel == NULL) {\n            sentinel = q;\n        }\n        if (--tries) {\n            continue;\n        }\n        wait = 1;\n        break;\n    }\n    ngx_shmtx_unlock(&cache->shpool->mutex);\n    ngx_free(name);\n    return wait;\n}', 'static void\nngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,\n    u_char *name)\n{\n    u_char                      *p;\n    size_t                       len;\n    ngx_path_t                  *path;\n    ngx_http_file_cache_node_t  *fcn;\n    fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);\n    if (fcn->exists) {\n        cache->sh->size -= fcn->fs_size;\n        path = cache->path;\n        p = name + path->name.len + 1 + path->len;\n        p = ngx_hex_dump(p, (u_char *) &fcn->node.key,\n                         sizeof(ngx_rbtree_key_t));\n        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);\n        p = ngx_hex_dump(p, fcn->key, len);\n        *p = \'\\0\';\n        fcn->count++;\n        fcn->deleting = 1;\n        ngx_shmtx_unlock(&cache->shpool->mutex);\n        len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;\n        ngx_create_hashed_filename(path, name, len);\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                       "http file cache expire: \\"%s\\"", name);\n        if (ngx_delete_file(name) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno,\n                          ngx_delete_file_n " \\"%s\\" failed", name);\n        }\n        ngx_shmtx_lock(&cache->shpool->mutex);\n        fcn->count--;\n        fcn->deleting = 0;\n    }\n    if (fcn->count == 0) {\n        ngx_queue_remove(q);\n        ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);\n        ngx_slab_free_locked(cache->shpool, fcn);\n        cache->sh->count--;\n    }\n}']