src/http/modules/ngx_http_uwsgi_module.c:1327: error: Buffer Overrun L3
  Offset: [0, 534] (⇐ [0, 24] + [0, 510]) Size: [0, +oo] by call to `ngx_http_upstream_hide_headers_hash`.

src/http/modules/ngx_http_uwsgi_module.c:1323:5: Assignment
1321.     ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
1322. 
1323.     hash.max_size = 512;
          ^
1324.     hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1325.     hash.name = "uwsgi_hide_headers_hash";

src/http/modules/ngx_http_uwsgi_module.c:1327:9: Call
1325.     hash.name = "uwsgi_hide_headers_hash";
1326. 
1327.     if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
              ^
1328.             &prev->upstream, ngx_http_uwsgi_hide_headers, &hash)
1329.         != NGX_OK)

src/http/ngx_http_upstream.c:4333:1: Parameter `hash->max_size`
  4331. 
  4332. 
  4333. ngx_int_t
        ^
  4334. ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
  4335.     ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,

src/http/ngx_http_upstream.c:4441:12: Call
  4439.     hash->temp_pool = NULL;
  4440. 
  4441.     return ngx_hash_init(hash, hide_headers.elts, hide_headers.nelts);
                   ^
  4442. }
  4443. 

src/core/ngx_hash.c:250:1: <Offset trace>
248.     (sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
249. 
250. ngx_int_t
     ^
251. ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
252. {

src/core/ngx_hash.c:250:1: Parameter `hinit->max_size`
    248.     (sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
    249. 
    250. ngx_int_t
         ^
    251. ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
    252. {

src/core/ngx_hash.c:250:1: <Length trace>
248.     (sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
249. 
250. ngx_int_t
     ^
251. ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
252. {

src/core/ngx_hash.c:250:1: Parameter `hinit->max_size`
    248.     (sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
    249. 
    250. ngx_int_t
         ^
    251. ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
    252. {

src/core/ngx_hash.c:363:19: Call
    361. 
    362.     } else {
    363.         buckets = ngx_pcalloc(hinit->pool, size * sizeof(ngx_hash_elt_t *));
                           ^
    364.         if (buckets == NULL) {
    365.             ngx_free(test);

src/core/ngx_palloc.c:299:1: Parameter `size`
      297. 
      298. 
      299. void *
           ^
      300. ngx_pcalloc(ngx_pool_t *pool, size_t size)
      301. {

src/core/ngx_palloc.c:304:9: Call
      302.     void *p;
      303. 
      304.     p = ngx_palloc(pool, size);
                   ^
      305.     if (p) {
      306.         ngx_memzero(p, size);

src/core/ngx_palloc.c:126:13: Assignment
        124. 
        125.         do {
        126.             m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);
                         ^
        127. 
        128.             if ((size_t) (p->d.end - m) >= size) {

src/core/ngx_palloc.c:131:17: Assignment
        129.                 p->d.last = m + size;
        130. 
        131.                 return m;
                             ^
        132.             }
        133. 

src/core/ngx_palloc.c:304:5: Assignment
      302.     void *p;
      303. 
      304.     p = ngx_palloc(pool, size);
               ^
      305.     if (p) {
      306.         ngx_memzero(p, size);

src/core/ngx_palloc.c:309:5: Assignment
      307.     }
      308. 
      309.     return p;
               ^
      310. }
      311. 

src/core/ngx_hash.c:363:9: Assignment
    361. 
    362.     } else {
    363.         buckets = ngx_pcalloc(hinit->pool, size * sizeof(ngx_hash_elt_t *));
                 ^
    364.         if (buckets == NULL) {
    365.             ngx_free(test);

src/core/ngx_hash.c:383:9: Array access: Offset: [0, 534] (⇐ [0, 24] + [0, 510]) Size: [0, +oo] by call to `ngx_http_upstream_hide_headers_hash` 
    381.         }
    382. 
    383.         buckets[i] = (ngx_hash_elt_t *) elts;
                 ^
    384.         elts += test[i];
    385. 

ngx_int_t
ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
{
    u_char          *elts;
    size_t           len;
    u_short         *test;
    ngx_uint_t       i, n, key, size, start, bucket_size;
    ngx_hash_elt_t  *elt, **buckets;
    for (n = 0; n < nelts; n++) {
        if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *))
        {
            ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,
                          "could not build the %s, you should "
                          "increase %s_bucket_size: %i",
                          hinit->name, hinit->name, hinit->bucket_size);
            return NGX_ERROR;
        }
    }
    test = ngx_alloc(hinit->max_size * sizeof(u_short), hinit->pool->log);
    if (test == NULL) {
        return NGX_ERROR;
    }
    bucket_size = hinit->bucket_size - sizeof(void *);
    start = nelts / (bucket_size / (2 * sizeof(void *)));
    start = start ? start : 1;
    if (hinit->max_size > 10000 && hinit->max_size / nelts < 100) {
        start = hinit->max_size - 1000;
    }
    for (size = start; size < hinit->max_size; size++) {
        ngx_memzero(test, size * sizeof(u_short));
        for (n = 0; n < nelts; n++) {
            if (names[n].key.data == NULL) {
                continue;
            }
            key = names[n].key_hash % size;
            test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
#if 0
            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
                          "%ui: %ui %ui \"%V\"",
                          size, key, test[key], &names[n].key);
#endif
            if (test[key] > (u_short) bucket_size) {
                goto next;
            }
        }
        goto found;
    next:
        continue;
    }
    ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,
                  "could not build the %s, you should increase "
                  "either %s_max_size: %i or %s_bucket_size: %i",
                  hinit->name, hinit->name, hinit->max_size,
                  hinit->name, hinit->bucket_size);
    ngx_free(test);
    return NGX_ERROR;
found:
    for (i = 0; i < size; i++) {
        test[i] = sizeof(void *);
    }
    for (n = 0; n < nelts; n++) {
        if (names[n].key.data == NULL) {
            continue;
        }
        key = names[n].key_hash % size;
        test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
    }
    len = 0;
    for (i = 0; i < size; i++) {
        if (test[i] == sizeof(void *)) {
            continue;
        }
        test[i] = (u_short) (ngx_align(test[i], ngx_cacheline_size));
        len += test[i];
    }
    if (hinit->hash == NULL) {
        hinit->hash = ngx_pcalloc(hinit->pool, sizeof(ngx_hash_wildcard_t)
                                             + size * sizeof(ngx_hash_elt_t *));
        if (hinit->hash == NULL) {
            ngx_free(test);
            return NGX_ERROR;
        }
        buckets = (ngx_hash_elt_t **)
                      ((u_char *) hinit->hash + sizeof(ngx_hash_wildcard_t));
    } else {
        buckets = ngx_pcalloc(hinit->pool, size * sizeof(ngx_hash_elt_t *));
        if (buckets == NULL) {
            ngx_free(test);
            return NGX_ERROR;
        }
    }
    elts = ngx_palloc(hinit->pool, len + ngx_cacheline_size);
    if (elts == NULL) {
        ngx_free(test);
        return NGX_ERROR;
    }
    elts = ngx_align_ptr(elts, ngx_cacheline_size);
    for (i = 0; i < size; i++) {
        if (test[i] == sizeof(void *)) {
            continue;
        }
        buckets[i] = (ngx_hash_elt_t *) elts;
        elts += test[i];
    }
    for (i = 0; i < size; i++) {
        test[i] = 0;
    }
    for (n = 0; n < nelts; n++) {
        if (names[n].key.data == NULL) {
            continue;
        }
        key = names[n].key_hash % size;
        elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]);
        elt->value = names[n].value;
        elt->len = (u_short) names[n].key.len;
        ngx_strlow(elt->name, names[n].key.data, names[n].key.len);
        test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
    }
    for (i = 0; i < size; i++) {
        if (buckets[i] == NULL) {
            continue;
        }
        elt = (ngx_hash_elt_t *) ((u_char *) buckets[i] + test[i]);
        elt->value = NULL;
    }
    ngx_free(test);
    hinit->hash->buckets = buckets;
    hinit->hash->size = size;
#if 0
    for (i = 0; i < size; i++) {
        ngx_str_t   val;
        ngx_uint_t  key;
        elt = buckets[i];
        if (elt == NULL) {
            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
                          "%ui: NULL", i);
            continue;
        }
        while (elt->value) {
            val.len = elt->len;
            val.data = &elt->name[0];
            key = hinit->key(val.data, val.len);
            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,
                          "%ui: %p \"%V\" %ui", i, elt, &val, key);
            elt = (ngx_hash_elt_t *) ngx_align_ptr(&elt->name[0] + elt->len,
                                                   sizeof(void *));
        }
    }
#endif
    return NGX_OK;
}
['static char *\nngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)\n{\n    ngx_http_uwsgi_loc_conf_t *prev = parent;\n    ngx_http_uwsgi_loc_conf_t *conf = child;\n    u_char                       *p;\n    size_t                        size;\n    uintptr_t                    *code;\n    ngx_uint_t                    i;\n    ngx_array_t                   headers_names;\n    ngx_keyval_t                 *src;\n    ngx_hash_key_t               *hk;\n    ngx_hash_init_t               hash;\n    ngx_http_script_compile_t     sc;\n    ngx_http_script_copy_code_t  *copy;\n    if (conf->upstream.store != 0) {\n        ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);\n        if (conf->upstream.store_lengths == NULL) {\n            conf->upstream.store_lengths = prev->upstream.store_lengths;\n            conf->upstream.store_values = prev->upstream.store_values;\n        }\n    }\n    ngx_conf_merge_uint_value(conf->upstream.store_access,\n                              prev->upstream.store_access, 0600);\n    ngx_conf_merge_value(conf->upstream.buffering,\n                              prev->upstream.buffering, 1);\n    ngx_conf_merge_value(conf->upstream.ignore_client_abort,\n                              prev->upstream.ignore_client_abort, 0);\n    ngx_conf_merge_msec_value(conf->upstream.connect_timeout,\n                              prev->upstream.connect_timeout, 60000);\n    ngx_conf_merge_msec_value(conf->upstream.send_timeout,\n                              prev->upstream.send_timeout, 60000);\n    ngx_conf_merge_msec_value(conf->upstream.read_timeout,\n                              prev->upstream.read_timeout, 60000);\n    ngx_conf_merge_size_value(conf->upstream.send_lowat,\n                              prev->upstream.send_lowat, 0);\n    ngx_conf_merge_size_value(conf->upstream.buffer_size,\n                              prev->upstream.buffer_size,\n                              (size_t) ngx_pagesize);\n    ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,\n                              8, ngx_pagesize);\n    if (conf->upstream.bufs.num < 2) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "there must be at least 2 \\"uwsgi_buffers\\"");\n        return NGX_CONF_ERROR;\n    }\n    size = conf->upstream.buffer_size;\n    if (size < conf->upstream.bufs.size) {\n        size = conf->upstream.bufs.size;\n    }\n    ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,\n                              prev->upstream.busy_buffers_size_conf,\n                              NGX_CONF_UNSET_SIZE);\n    if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {\n        conf->upstream.busy_buffers_size = 2 * size;\n    } else {\n        conf->upstream.busy_buffers_size =\n            conf->upstream.busy_buffers_size_conf;\n    }\n    if (conf->upstream.busy_buffers_size < size) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n            "\\"uwsgi_busy_buffers_size\\" must be equal or bigger "\n            "than maximum of the value of \\"uwsgi_buffer_size\\" and "\n            "one of the \\"uwsgi_buffers\\"");\n        return NGX_CONF_ERROR;\n    }\n    if (conf->upstream.busy_buffers_size\n        > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)\n    {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n            "\\"uwsgi_busy_buffers_size\\" must be less than "\n            "the size of all \\"uwsgi_buffers\\" minus one buffer");\n        return NGX_CONF_ERROR;\n    }\n    ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,\n                              prev->upstream.temp_file_write_size_conf,\n                              NGX_CONF_UNSET_SIZE);\n    if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {\n        conf->upstream.temp_file_write_size = 2 * size;\n    } else {\n        conf->upstream.temp_file_write_size =\n            conf->upstream.temp_file_write_size_conf;\n    }\n    if (conf->upstream.temp_file_write_size < size) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n            "\\"uwsgi_temp_file_write_size\\" must be equal or bigger than "\n            "maximum of the value of \\"uwsgi_buffer_size\\" and "\n            "one of the \\"uwsgi_buffers\\"");\n        return NGX_CONF_ERROR;\n    }\n    ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,\n                              prev->upstream.max_temp_file_size_conf,\n                              NGX_CONF_UNSET_SIZE);\n    if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {\n        conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;\n    } else {\n        conf->upstream.max_temp_file_size =\n            conf->upstream.max_temp_file_size_conf;\n    }\n    if (conf->upstream.max_temp_file_size != 0\n        && conf->upstream.max_temp_file_size < size) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n            "\\"uwsgi_max_temp_file_size\\" must be equal to zero to disable "\n            "the temporary files usage or must be equal or bigger than "\n            "maximum of the value of \\"uwsgi_buffer_size\\" and "\n            "one of the \\"uwsgi_buffers\\"");\n        return NGX_CONF_ERROR;\n    }\n    ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,\n                                 prev->upstream.ignore_headers,\n                                 NGX_CONF_BITMASK_SET);\n    ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,\n                                 prev->upstream.next_upstream,\n                                 (NGX_CONF_BITMASK_SET\n                                  |NGX_HTTP_UPSTREAM_FT_ERROR\n                                  |NGX_HTTP_UPSTREAM_FT_TIMEOUT));\n    if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {\n        conf->upstream.next_upstream = NGX_CONF_BITMASK_SET\n                                       |NGX_HTTP_UPSTREAM_FT_OFF;\n    }\n    if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,\n                                  prev->upstream.temp_path,\n                                  &ngx_http_uwsgi_temp_path)\n        != NGX_OK)\n    {\n        return NGX_CONF_ERROR;\n    }\n#if (NGX_HTTP_CACHE)\n    ngx_conf_merge_ptr_value(conf->upstream.cache,\n                              prev->upstream.cache, NULL);\n    if (conf->upstream.cache && conf->upstream.cache->data == NULL) {\n        ngx_shm_zone_t  *shm_zone;\n        shm_zone = conf->upstream.cache;\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "\\"uwsgi_cache\\" zone \\"%V\\" is unknown",\n                           &shm_zone->shm.name);\n        return NGX_CONF_ERROR;\n    }\n    ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,\n                              prev->upstream.cache_min_uses, 1);\n    ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale,\n                              prev->upstream.cache_use_stale,\n                              (NGX_CONF_BITMASK_SET\n                               |NGX_HTTP_UPSTREAM_FT_OFF));\n    if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) {\n        conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET\n                                         |NGX_HTTP_UPSTREAM_FT_OFF;\n    }\n    if (conf->upstream.cache_methods == 0) {\n        conf->upstream.cache_methods = prev->upstream.cache_methods;\n    }\n    conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD;\n    ngx_conf_merge_ptr_value(conf->upstream.cache_bypass,\n                             prev->upstream.cache_bypass, NULL);\n    ngx_conf_merge_ptr_value(conf->upstream.no_cache,\n                             prev->upstream.no_cache, NULL);\n    ngx_conf_merge_ptr_value(conf->upstream.cache_valid,\n                             prev->upstream.cache_valid, NULL);\n    if (conf->cache_key.value.data == NULL) {\n        conf->cache_key = prev->cache_key;\n    }\n#endif\n    ngx_conf_merge_value(conf->upstream.pass_request_headers,\n                         prev->upstream.pass_request_headers, 1);\n    ngx_conf_merge_value(conf->upstream.pass_request_body,\n                         prev->upstream.pass_request_body, 1);\n    ngx_conf_merge_value(conf->upstream.intercept_errors,\n                         prev->upstream.intercept_errors, 0);\n    ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");\n    hash.max_size = 512;\n    hash.bucket_size = ngx_align(64, ngx_cacheline_size);\n    hash.name = "uwsgi_hide_headers_hash";\n    if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,\n            &prev->upstream, ngx_http_uwsgi_hide_headers, &hash)\n        != NGX_OK)\n    {\n        return NGX_CONF_ERROR;\n    }\n    if (conf->upstream.upstream == NULL) {\n        conf->upstream.upstream = prev->upstream.upstream;\n    }\n    if (conf->uwsgi_lengths == NULL) {\n        conf->uwsgi_lengths = prev->uwsgi_lengths;\n        conf->uwsgi_values = prev->uwsgi_values;\n    }\n    ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);\n    ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);\n    if (conf->params_source == NULL) {\n        conf->flushes = prev->flushes;\n        conf->params_len = prev->params_len;\n        conf->params = prev->params;\n        conf->params_source = prev->params_source;\n        conf->headers_hash = prev->headers_hash;\n#if (NGX_HTTP_CACHE)\n        if (conf->params_source == NULL) {\n            if ((conf->upstream.cache == NULL)\n                == (prev->upstream.cache == NULL))\n            {\n                return NGX_CONF_OK;\n            }\n            conf->params_source = ngx_array_create(cf->pool, 6,\n                                                   sizeof(ngx_keyval_t));\n            if (conf->params_source == NULL) {\n                return NGX_CONF_ERROR;\n            }\n        }\n#else\n        if (conf->params_source == NULL) {\n            return NGX_CONF_OK;\n        }\n#endif\n    }\n    conf->params_len = ngx_array_create(cf->pool, 64, 1);\n    if (conf->params_len == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    conf->params = ngx_array_create(cf->pool, 512, 1);\n    if (conf->params == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))\n        != NGX_OK)\n    {\n        return NGX_CONF_ERROR;\n    }\n    src = conf->params_source->elts;\n#if (NGX_HTTP_CACHE)\n    if (conf->upstream.cache) {\n        ngx_keyval_t  *h, *s;\n        for (h = ngx_http_uwsgi_cache_headers; h->key.len; h++) {\n            for (i = 0; i < conf->params_source->nelts; i++) {\n                if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {\n                    goto next;\n                }\n            }\n            s = ngx_array_push(conf->params_source);\n            if (s == NULL) {\n                return NGX_CONF_ERROR;\n            }\n            *s = *h;\n            src = conf->params_source->elts;\n        next:\n            h++;\n        }\n    }\n#endif\n    for (i = 0; i < conf->params_source->nelts; i++) {\n        if (src[i].key.len > sizeof("HTTP_") - 1\n            && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0)\n        {\n            hk = ngx_array_push(&headers_names);\n            if (hk == NULL) {\n                return NGX_CONF_ERROR;\n            }\n            hk->key.len = src[i].key.len - 5;\n            hk->key.data = src[i].key.data + 5;\n            hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len);\n            hk->value = (void *) 1;\n            if (src[i].value.len == 0) {\n                continue;\n            }\n        }\n        copy = ngx_array_push_n(conf->params_len,\n                                sizeof(ngx_http_script_copy_code_t));\n        if (copy == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;\n        copy->len = src[i].key.len;\n        size = (sizeof(ngx_http_script_copy_code_t)\n                + src[i].key.len + sizeof(uintptr_t) - 1)\n               & ~(sizeof(uintptr_t) - 1);\n        copy = ngx_array_push_n(conf->params, size);\n        if (copy == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        copy->code = ngx_http_script_copy_code;\n        copy->len = src[i].key.len;\n        p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);\n        ngx_memcpy(p, src[i].key.data, src[i].key.len);\n        ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));\n        sc.cf = cf;\n        sc.source = &src[i].value;\n        sc.flushes = &conf->flushes;\n        sc.lengths = &conf->params_len;\n        sc.values = &conf->params;\n        if (ngx_http_script_compile(&sc) != NGX_OK) {\n            return NGX_CONF_ERROR;\n        }\n        code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));\n        if (code == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        *code = (uintptr_t) NULL;\n        code = ngx_array_push_n(conf->params, sizeof(uintptr_t));\n        if (code == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        *code = (uintptr_t) NULL;\n    }\n    code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));\n    if (code == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    *code = (uintptr_t) NULL;\n    conf->header_params = headers_names.nelts;\n    hash.hash = &conf->headers_hash;\n    hash.key = ngx_hash_key_lc;\n    hash.max_size = 512;\n    hash.bucket_size = 64;\n    hash.name = "uwsgi_params_hash";\n    hash.pool = cf->pool;\n    hash.temp_pool = NULL;\n    if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK)\n    {\n        return NGX_CONF_ERROR;\n    }\n    return NGX_CONF_OK;\n}', 'ngx_int_t\nngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,\n    ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,\n    ngx_str_t *default_hide_headers, ngx_hash_init_t *hash)\n{\n    ngx_str_t       *h;\n    ngx_uint_t       i, j;\n    ngx_array_t      hide_headers;\n    ngx_hash_key_t  *hk;\n    if (conf->hide_headers == NGX_CONF_UNSET_PTR\n        && conf->pass_headers == NGX_CONF_UNSET_PTR)\n    {\n        conf->hide_headers_hash = prev->hide_headers_hash;\n        if (conf->hide_headers_hash.buckets\n#if (NGX_HTTP_CACHE)\n            && ((conf->cache == NULL) == (prev->cache == NULL))\n#endif\n           )\n        {\n            return NGX_OK;\n        }\n        conf->hide_headers = prev->hide_headers;\n        conf->pass_headers = prev->pass_headers;\n    } else {\n        if (conf->hide_headers == NGX_CONF_UNSET_PTR) {\n            conf->hide_headers = prev->hide_headers;\n        }\n        if (conf->pass_headers == NGX_CONF_UNSET_PTR) {\n            conf->pass_headers = prev->pass_headers;\n        }\n    }\n    if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))\n        != NGX_OK)\n    {\n        return NGX_ERROR;\n    }\n    for (h = default_hide_headers; h->len; h++) {\n        hk = ngx_array_push(&hide_headers);\n        if (hk == NULL) {\n            return NGX_ERROR;\n        }\n        hk->key = *h;\n        hk->key_hash = ngx_hash_key_lc(h->data, h->len);\n        hk->value = (void *) 1;\n    }\n    if (conf->hide_headers != NGX_CONF_UNSET_PTR) {\n        h = conf->hide_headers->elts;\n        for (i = 0; i < conf->hide_headers->nelts; i++) {\n            hk = hide_headers.elts;\n            for (j = 0; j < hide_headers.nelts; j++) {\n                if (ngx_strcasecmp(h[i].data, hk[j].key.data) == 0) {\n                    goto exist;\n                }\n            }\n            hk = ngx_array_push(&hide_headers);\n            if (hk == NULL) {\n                return NGX_ERROR;\n            }\n            hk->key = h[i];\n            hk->key_hash = ngx_hash_key_lc(h[i].data, h[i].len);\n            hk->value = (void *) 1;\n        exist:\n            continue;\n        }\n    }\n    if (conf->pass_headers != NGX_CONF_UNSET_PTR) {\n        h = conf->pass_headers->elts;\n        hk = hide_headers.elts;\n        for (i = 0; i < conf->pass_headers->nelts; i++) {\n            for (j = 0; j < hide_headers.nelts; j++) {\n                if (hk[j].key.data == NULL) {\n                    continue;\n                }\n                if (ngx_strcasecmp(h[i].data, hk[j].key.data) == 0) {\n                    hk[j].key.data = NULL;\n                    break;\n                }\n            }\n        }\n    }\n    hash->hash = &conf->hide_headers_hash;\n    hash->key = ngx_hash_key_lc;\n    hash->pool = cf->pool;\n    hash->temp_pool = NULL;\n    return ngx_hash_init(hash, hide_headers.elts, hide_headers.nelts);\n}', 'ngx_int_t\nngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)\n{\n    u_char          *elts;\n    size_t           len;\n    u_short         *test;\n    ngx_uint_t       i, n, key, size, start, bucket_size;\n    ngx_hash_elt_t  *elt, **buckets;\n    for (n = 0; n < nelts; n++) {\n        if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *))\n        {\n            ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,\n                          "could not build the %s, you should "\n                          "increase %s_bucket_size: %i",\n                          hinit->name, hinit->name, hinit->bucket_size);\n            return NGX_ERROR;\n        }\n    }\n    test = ngx_alloc(hinit->max_size * sizeof(u_short), hinit->pool->log);\n    if (test == NULL) {\n        return NGX_ERROR;\n    }\n    bucket_size = hinit->bucket_size - sizeof(void *);\n    start = nelts / (bucket_size / (2 * sizeof(void *)));\n    start = start ? start : 1;\n    if (hinit->max_size > 10000 && hinit->max_size / nelts < 100) {\n        start = hinit->max_size - 1000;\n    }\n    for (size = start; size < hinit->max_size; size++) {\n        ngx_memzero(test, size * sizeof(u_short));\n        for (n = 0; n < nelts; n++) {\n            if (names[n].key.data == NULL) {\n                continue;\n            }\n            key = names[n].key_hash % size;\n            test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));\n#if 0\n            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,\n                          "%ui: %ui %ui \\"%V\\"",\n                          size, key, test[key], &names[n].key);\n#endif\n            if (test[key] > (u_short) bucket_size) {\n                goto next;\n            }\n        }\n        goto found;\n    next:\n        continue;\n    }\n    ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,\n                  "could not build the %s, you should increase "\n                  "either %s_max_size: %i or %s_bucket_size: %i",\n                  hinit->name, hinit->name, hinit->max_size,\n                  hinit->name, hinit->bucket_size);\n    ngx_free(test);\n    return NGX_ERROR;\nfound:\n    for (i = 0; i < size; i++) {\n        test[i] = sizeof(void *);\n    }\n    for (n = 0; n < nelts; n++) {\n        if (names[n].key.data == NULL) {\n            continue;\n        }\n        key = names[n].key_hash % size;\n        test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));\n    }\n    len = 0;\n    for (i = 0; i < size; i++) {\n        if (test[i] == sizeof(void *)) {\n            continue;\n        }\n        test[i] = (u_short) (ngx_align(test[i], ngx_cacheline_size));\n        len += test[i];\n    }\n    if (hinit->hash == NULL) {\n        hinit->hash = ngx_pcalloc(hinit->pool, sizeof(ngx_hash_wildcard_t)\n                                             + size * sizeof(ngx_hash_elt_t *));\n        if (hinit->hash == NULL) {\n            ngx_free(test);\n            return NGX_ERROR;\n        }\n        buckets = (ngx_hash_elt_t **)\n                      ((u_char *) hinit->hash + sizeof(ngx_hash_wildcard_t));\n    } else {\n        buckets = ngx_pcalloc(hinit->pool, size * sizeof(ngx_hash_elt_t *));\n        if (buckets == NULL) {\n            ngx_free(test);\n            return NGX_ERROR;\n        }\n    }\n    elts = ngx_palloc(hinit->pool, len + ngx_cacheline_size);\n    if (elts == NULL) {\n        ngx_free(test);\n        return NGX_ERROR;\n    }\n    elts = ngx_align_ptr(elts, ngx_cacheline_size);\n    for (i = 0; i < size; i++) {\n        if (test[i] == sizeof(void *)) {\n            continue;\n        }\n        buckets[i] = (ngx_hash_elt_t *) elts;\n        elts += test[i];\n    }\n    for (i = 0; i < size; i++) {\n        test[i] = 0;\n    }\n    for (n = 0; n < nelts; n++) {\n        if (names[n].key.data == NULL) {\n            continue;\n        }\n        key = names[n].key_hash % size;\n        elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]);\n        elt->value = names[n].value;\n        elt->len = (u_short) names[n].key.len;\n        ngx_strlow(elt->name, names[n].key.data, names[n].key.len);\n        test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));\n    }\n    for (i = 0; i < size; i++) {\n        if (buckets[i] == NULL) {\n            continue;\n        }\n        elt = (ngx_hash_elt_t *) ((u_char *) buckets[i] + test[i]);\n        elt->value = NULL;\n    }\n    ngx_free(test);\n    hinit->hash->buckets = buckets;\n    hinit->hash->size = size;\n#if 0\n    for (i = 0; i < size; i++) {\n        ngx_str_t   val;\n        ngx_uint_t  key;\n        elt = buckets[i];\n        if (elt == NULL) {\n            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,\n                          "%ui: NULL", i);\n            continue;\n        }\n        while (elt->value) {\n            val.len = elt->len;\n            val.data = &elt->name[0];\n            key = hinit->key(val.data, val.len);\n            ngx_log_error(NGX_LOG_ALERT, hinit->pool->log, 0,\n                          "%ui: %p \\"%V\\" %ui", i, elt, &val, key);\n            elt = (ngx_hash_elt_t *) ngx_align_ptr(&elt->name[0] + elt->len,\n                                                   sizeof(void *));\n        }\n    }\n#endif\n    return NGX_OK;\n}', 'void *\nngx_pcalloc(ngx_pool_t *pool, size_t size)\n{\n    void *p;\n    p = ngx_palloc(pool, size);\n    if (p) {\n        ngx_memzero(p, size);\n    }\n    return p;\n}', 'void *\nngx_palloc(ngx_pool_t *pool, size_t size)\n{\n    u_char      *m;\n    ngx_pool_t  *p;\n    if (size <= pool->max) {\n        p = pool->current;\n        do {\n            m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);\n            if ((size_t) (p->d.end - m) >= size) {\n                p->d.last = m + size;\n                return m;\n            }\n            p = p->d.next;\n        } while (p);\n        return ngx_palloc_block(pool, size);\n    }\n    return ngx_palloc_large(pool, size);\n}']