src/http/ngx_http_upstream.c:1012: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `ngx_http_upstream_finalize_request`.

src/http/ngx_http_upstream.c:1007:9: Call
1005. 
1006.     if (ctx->state) {
1007.         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
              ^
1008.                       "%V could not be resolved (%i: %s)",
1009.                       &ctx->name, ctx->state,

src/core/ngx_log.c:78:1: Parameter `log->next->disk_full_time`
  76. #if (NGX_HAVE_VARIADIC_MACROS)
  77. 
  78. void
      ^
  79. ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
  80.     const char *fmt, ...)

src/http/ngx_http_upstream.c:1012:9: Call
1010.                       ngx_resolver_strerror(ctx->state));
1011. 
1012.         ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
              ^
1013.         goto failed;
1014.     }

src/http/ngx_http_upstream.c:3737:1: Parameter `r->main->count`
  3735. 
  3736. 
  3737. static void
        ^
  3738. ngx_http_upstream_finalize_request(ngx_http_request_t *r,
  3739.     ngx_http_upstream_t *u, ngx_int_t rc)

src/http/ngx_http_upstream.c:3864:9: Call
  3862.         || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST)
  3863.     {
  3864.         ngx_http_finalize_request(r, rc);
                ^
  3865.         return;
  3866.     }

src/http/ngx_http_request.c:2248:1: <LHS trace>
2246. 
2247. 
2248. void
      ^
2249. ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
2250. {

src/http/ngx_http_request.c:2248:1: Parameter `r->main->count`
    2246. 
    2247. 
    2248. void
          ^
    2249. ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
    2250. {

src/http/ngx_http_request.c:2339:13: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ngx_http_upstream_finalize_request` 
    2337.         if (r == c->data) {
    2338. 
    2339.             r->main->count--;
                      ^
    2340.             r->main->subrequests++;
    2341. 

void
ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
{
    ngx_connection_t          *c;
    ngx_http_request_t        *pr;
    ngx_http_core_loc_conf_t  *clcf;
    c = r->connection;
    ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0,
                   "http finalize request: %d, \"%V?%V\" a:%d, c:%d",
                   rc, &r->uri, &r->args, r == c->data, r->main->count);
    if (rc == NGX_DONE) {
        ngx_http_finalize_connection(r);
        return;
    }
    if (rc == NGX_OK && r->filter_finalize) {
        c->error = 1;
    }
    if (rc == NGX_DECLINED) {
        r->content_handler = NULL;
        r->write_event_handler = ngx_http_core_run_phases;
        ngx_http_core_run_phases(r);
        return;
    }
    if (r != r->main && r->post_subrequest) {
        rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);
    }
    if (rc == NGX_ERROR
        || rc == NGX_HTTP_REQUEST_TIME_OUT
        || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST
        || c->error)
    {
        if (ngx_http_post_action(r) == NGX_OK) {
            return;
        }
        if (r->main->blocked) {
            r->write_event_handler = ngx_http_request_finalizer;
        }
        ngx_http_terminate_request(r, rc);
        return;
    }
    if (rc >= NGX_HTTP_SPECIAL_RESPONSE
        || rc == NGX_HTTP_CREATED
        || rc == NGX_HTTP_NO_CONTENT)
    {
        if (rc == NGX_HTTP_CLOSE) {
            ngx_http_terminate_request(r, rc);
            return;
        }
        if (r == r->main) {
            if (c->read->timer_set) {
                ngx_del_timer(c->read);
            }
            if (c->write->timer_set) {
                ngx_del_timer(c->write);
            }
        }
        c->read->handler = ngx_http_request_handler;
        c->write->handler = ngx_http_request_handler;
        ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
        return;
    }
    if (r != r->main) {
        if (r->buffered || r->postponed) {
            if (ngx_http_set_write_handler(r) != NGX_OK) {
                ngx_http_terminate_request(r, 0);
            }
            return;
        }
        pr = r->parent;
        if (r == c->data) {
            r->main->count--;
            r->main->subrequests++;
            if (!r->logged) {
                clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
                if (clcf->log_subrequest) {
                    ngx_http_log_request(r);
                }
                r->logged = 1;
            } else {
                ngx_log_error(NGX_LOG_ALERT, c->log, 0,
                              "subrequest: \"%V?%V\" logged again",
                              &r->uri, &r->args);
            }
            r->done = 1;
            if (pr->postponed && pr->postponed->request == r) {
                pr->postponed = pr->postponed->next;
            }
            c->data = pr;
        } else {
            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                           "http finalize non-active request: \"%V?%V\"",
                           &r->uri, &r->args);
            r->write_event_handler = ngx_http_request_finalizer;
            if (r->waited) {
                r->done = 1;
            }
        }
        if (ngx_http_post_request(pr, NULL) != NGX_OK) {
            r->main->count++;
            ngx_http_terminate_request(r, 0);
            return;
        }
        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                       "http wake parent request: \"%V?%V\"",
                       &pr->uri, &pr->args);
        return;
    }
    if (r->buffered || c->buffered || r->postponed || r->blocked) {
        if (ngx_http_set_write_handler(r) != NGX_OK) {
            ngx_http_terminate_request(r, 0);
        }
        return;
    }
    if (r != c->data) {
        ngx_log_error(NGX_LOG_ALERT, c->log, 0,
                      "http finalize non-active request: \"%V?%V\"",
                      &r->uri, &r->args);
        return;
    }
    r->done = 1;
    r->write_event_handler = ngx_http_request_empty_handler;
    if (!r->post_action) {
        r->request_complete = 1;
    }
    if (ngx_http_post_action(r) == NGX_OK) {
        return;
    }
    if (c->read->timer_set) {
        ngx_del_timer(c->read);
    }
    if (c->write->timer_set) {
        c->write->delayed = 0;
        ngx_del_timer(c->write);
    }
    if (c->read->eof) {
        ngx_http_close_request(r, 0);
        return;
    }
    ngx_http_finalize_connection(r);
}
['static void\nngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)\n{\n    ngx_connection_t              *c;\n    ngx_http_request_t            *r;\n    ngx_http_upstream_t           *u;\n    ngx_http_upstream_resolved_t  *ur;\n    r = ctx->data;\n    c = r->connection;\n    u = r->upstream;\n    ur = u->resolved;\n    ngx_http_set_log_request(c->log, r);\n    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                   "http upstream resolve: \\"%V?%V\\"", &r->uri, &r->args);\n    if (ctx->state) {\n        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                      "%V could not be resolved (%i: %s)",\n                      &ctx->name, ctx->state,\n                      ngx_resolver_strerror(ctx->state));\n        ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);\n        goto failed;\n    }\n    ur->naddrs = ctx->naddrs;\n    ur->addrs = ctx->addrs;\n#if (NGX_DEBUG)\n    {\n    u_char      text[NGX_SOCKADDR_STRLEN];\n    ngx_str_t   addr;\n    ngx_uint_t  i;\n    addr.data = text;\n    for (i = 0; i < ctx->naddrs; i++) {\n        addr.len = ngx_sock_ntop(ur->addrs[i].sockaddr, ur->addrs[i].socklen,\n                                 text, NGX_SOCKADDR_STRLEN, 0);\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "name was resolved to %V", &addr);\n    }\n    }\n#endif\n    if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) {\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_INTERNAL_SERVER_ERROR);\n        goto failed;\n    }\n    ngx_resolve_name_done(ctx);\n    ur->ctx = NULL;\n    u->peer.start_time = ngx_current_msec;\n    if (u->conf->next_upstream_tries\n        && u->peer.tries > u->conf->next_upstream_tries)\n    {\n        u->peer.tries = u->conf->next_upstream_tries;\n    }\n    ngx_http_upstream_connect(r, u);\nfailed:\n    ngx_http_run_posted_requests(c);\n}', 'void\nngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,\n    const char *fmt, ...)\n#else\nvoid\nngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,\n    const char *fmt, va_list args)\n#endif\n{\n#if (NGX_HAVE_VARIADIC_MACROS)\n    va_list      args;\n#endif\n    u_char      *p, *last, *msg;\n    ssize_t      n;\n    ngx_uint_t   wrote_stderr, debug_connection;\n    u_char       errstr[NGX_MAX_ERROR_STR];\n    last = errstr + NGX_MAX_ERROR_STR;\n    ngx_memcpy(errstr, ngx_cached_err_log_time.data,\n               ngx_cached_err_log_time.len);\n    p = errstr + ngx_cached_err_log_time.len;\n    p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);\n    p = ngx_slprintf(p, last, "%P#" NGX_TID_T_FMT ": ",\n                    ngx_log_pid, ngx_log_tid);\n    if (log->connection) {\n        p = ngx_slprintf(p, last, "*%uA ", log->connection);\n    }\n    msg = p;\n#if (NGX_HAVE_VARIADIC_MACROS)\n    va_start(args, fmt);\n    p = ngx_vslprintf(p, last, fmt, args);\n    va_end(args);\n#else\n    p = ngx_vslprintf(p, last, fmt, args);\n#endif\n    if (err) {\n        p = ngx_log_errno(p, last, err);\n    }\n    if (level != NGX_LOG_DEBUG && log->handler) {\n        p = log->handler(log, p, last - p);\n    }\n    if (p > last - NGX_LINEFEED_SIZE) {\n        p = last - NGX_LINEFEED_SIZE;\n    }\n    ngx_linefeed(p);\n    wrote_stderr = 0;\n    debug_connection = (log->log_level & NGX_LOG_DEBUG_CONNECTION) != 0;\n    while (log) {\n        if (log->log_level < level && !debug_connection) {\n            break;\n        }\n        if (log->writer) {\n            log->writer(log, level, errstr, p - errstr);\n            goto next;\n        }\n        if (ngx_time() == log->disk_full_time) {\n            goto next;\n        }\n        n = ngx_write_fd(log->file->fd, errstr, p - errstr);\n        if (n == -1 && ngx_errno == NGX_ENOSPC) {\n            log->disk_full_time = ngx_time();\n        }\n        if (log->file->fd == ngx_stderr) {\n            wrote_stderr = 1;\n        }\n    next:\n        log = log->next;\n    }\n    if (!ngx_use_stderr\n        || level > NGX_LOG_WARN\n        || wrote_stderr)\n    {\n        return;\n    }\n    msg -= (7 + err_levels[level].len + 3);\n    (void) ngx_sprintf(msg, "nginx: [%V] ", &err_levels[level]);\n    (void) ngx_write_console(ngx_stderr, msg, p - msg);\n}', 'static void\nngx_http_upstream_finalize_request(ngx_http_request_t *r,\n    ngx_http_upstream_t *u, ngx_int_t rc)\n{\n    ngx_uint_t   flush;\n    ngx_time_t  *tp;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "finalize http upstream request: %i", rc);\n    if (u->cleanup) {\n        *u->cleanup = NULL;\n        u->cleanup = NULL;\n    }\n    if (u->resolved && u->resolved->ctx) {\n        ngx_resolve_name_done(u->resolved->ctx);\n        u->resolved->ctx = NULL;\n    }\n    if (u->state && u->state->response_sec) {\n        tp = ngx_timeofday();\n        u->state->response_sec = tp->sec - u->state->response_sec;\n        u->state->response_msec = tp->msec - u->state->response_msec;\n        if (u->pipe && u->pipe->read_length) {\n            u->state->response_length = u->pipe->read_length;\n        }\n    }\n    u->finalize_request(r, rc);\n    if (u->peer.free && u->peer.sockaddr) {\n        u->peer.free(&u->peer, u->peer.data, 0);\n        u->peer.sockaddr = NULL;\n    }\n    if (u->peer.connection) {\n#if (NGX_HTTP_SSL)\n        if (u->peer.connection->ssl) {\n            u->peer.connection->ssl->no_wait_shutdown = 1;\n            (void) ngx_ssl_shutdown(u->peer.connection);\n        }\n#endif\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "close http upstream connection: %d",\n                       u->peer.connection->fd);\n        if (u->peer.connection->pool) {\n            ngx_destroy_pool(u->peer.connection->pool);\n        }\n        ngx_close_connection(u->peer.connection);\n    }\n    u->peer.connection = NULL;\n    if (u->pipe && u->pipe->temp_file) {\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http upstream temp fd: %d",\n                       u->pipe->temp_file->file.fd);\n    }\n    if (u->store && u->pipe && u->pipe->temp_file\n        && u->pipe->temp_file->file.fd != NGX_INVALID_FILE)\n    {\n        if (ngx_delete_file(u->pipe->temp_file->file.name.data)\n            == NGX_FILE_ERROR)\n        {\n            ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,\n                          ngx_delete_file_n " \\"%s\\" failed",\n                          u->pipe->temp_file->file.name.data);\n        }\n    }\n#if (NGX_HTTP_CACHE)\n    if (r->cache) {\n        if (u->cacheable) {\n            if (rc == NGX_HTTP_BAD_GATEWAY || rc == NGX_HTTP_GATEWAY_TIME_OUT) {\n                time_t  valid;\n                valid = ngx_http_file_cache_valid(u->conf->cache_valid, rc);\n                if (valid) {\n                    r->cache->valid_sec = ngx_time() + valid;\n                    r->cache->error = rc;\n                }\n            }\n        }\n        ngx_http_file_cache_free(r->cache, u->pipe->temp_file);\n    }\n#endif\n    if (r->subrequest_in_memory\n        && u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE)\n    {\n        u->buffer.last = u->buffer.pos;\n    }\n    if (rc == NGX_DECLINED) {\n        return;\n    }\n    r->connection->log->action = "sending to client";\n    if (!u->header_sent\n        || rc == NGX_HTTP_REQUEST_TIME_OUT\n        || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST)\n    {\n        ngx_http_finalize_request(r, rc);\n        return;\n    }\n    flush = 0;\n    if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {\n        rc = NGX_ERROR;\n        flush = 1;\n    }\n    if (r->header_only) {\n        ngx_http_finalize_request(r, rc);\n        return;\n    }\n    if (rc == 0) {\n        rc = ngx_http_send_special(r, NGX_HTTP_LAST);\n    } else if (flush) {\n        r->keepalive = 0;\n        rc = ngx_http_send_special(r, NGX_HTTP_FLUSH);\n    }\n    ngx_http_finalize_request(r, rc);\n}', 'void\nngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)\n{\n    ngx_connection_t          *c;\n    ngx_http_request_t        *pr;\n    ngx_http_core_loc_conf_t  *clcf;\n    c = r->connection;\n    ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                   "http finalize request: %d, \\"%V?%V\\" a:%d, c:%d",\n                   rc, &r->uri, &r->args, r == c->data, r->main->count);\n    if (rc == NGX_DONE) {\n        ngx_http_finalize_connection(r);\n        return;\n    }\n    if (rc == NGX_OK && r->filter_finalize) {\n        c->error = 1;\n    }\n    if (rc == NGX_DECLINED) {\n        r->content_handler = NULL;\n        r->write_event_handler = ngx_http_core_run_phases;\n        ngx_http_core_run_phases(r);\n        return;\n    }\n    if (r != r->main && r->post_subrequest) {\n        rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);\n    }\n    if (rc == NGX_ERROR\n        || rc == NGX_HTTP_REQUEST_TIME_OUT\n        || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST\n        || c->error)\n    {\n        if (ngx_http_post_action(r) == NGX_OK) {\n            return;\n        }\n        if (r->main->blocked) {\n            r->write_event_handler = ngx_http_request_finalizer;\n        }\n        ngx_http_terminate_request(r, rc);\n        return;\n    }\n    if (rc >= NGX_HTTP_SPECIAL_RESPONSE\n        || rc == NGX_HTTP_CREATED\n        || rc == NGX_HTTP_NO_CONTENT)\n    {\n        if (rc == NGX_HTTP_CLOSE) {\n            ngx_http_terminate_request(r, rc);\n            return;\n        }\n        if (r == r->main) {\n            if (c->read->timer_set) {\n                ngx_del_timer(c->read);\n            }\n            if (c->write->timer_set) {\n                ngx_del_timer(c->write);\n            }\n        }\n        c->read->handler = ngx_http_request_handler;\n        c->write->handler = ngx_http_request_handler;\n        ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));\n        return;\n    }\n    if (r != r->main) {\n        if (r->buffered || r->postponed) {\n            if (ngx_http_set_write_handler(r) != NGX_OK) {\n                ngx_http_terminate_request(r, 0);\n            }\n            return;\n        }\n        pr = r->parent;\n        if (r == c->data) {\n            r->main->count--;\n            r->main->subrequests++;\n            if (!r->logged) {\n                clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n                if (clcf->log_subrequest) {\n                    ngx_http_log_request(r);\n                }\n                r->logged = 1;\n            } else {\n                ngx_log_error(NGX_LOG_ALERT, c->log, 0,\n                              "subrequest: \\"%V?%V\\" logged again",\n                              &r->uri, &r->args);\n            }\n            r->done = 1;\n            if (pr->postponed && pr->postponed->request == r) {\n                pr->postponed = pr->postponed->next;\n            }\n            c->data = pr;\n        } else {\n            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                           "http finalize non-active request: \\"%V?%V\\"",\n                           &r->uri, &r->args);\n            r->write_event_handler = ngx_http_request_finalizer;\n            if (r->waited) {\n                r->done = 1;\n            }\n        }\n        if (ngx_http_post_request(pr, NULL) != NGX_OK) {\n            r->main->count++;\n            ngx_http_terminate_request(r, 0);\n            return;\n        }\n        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                       "http wake parent request: \\"%V?%V\\"",\n                       &pr->uri, &pr->args);\n        return;\n    }\n    if (r->buffered || c->buffered || r->postponed || r->blocked) {\n        if (ngx_http_set_write_handler(r) != NGX_OK) {\n            ngx_http_terminate_request(r, 0);\n        }\n        return;\n    }\n    if (r != c->data) {\n        ngx_log_error(NGX_LOG_ALERT, c->log, 0,\n                      "http finalize non-active request: \\"%V?%V\\"",\n                      &r->uri, &r->args);\n        return;\n    }\n    r->done = 1;\n    r->write_event_handler = ngx_http_request_empty_handler;\n    if (!r->post_action) {\n        r->request_complete = 1;\n    }\n    if (ngx_http_post_action(r) == NGX_OK) {\n        return;\n    }\n    if (c->read->timer_set) {\n        ngx_del_timer(c->read);\n    }\n    if (c->write->timer_set) {\n        c->write->delayed = 0;\n        ngx_del_timer(c->write);\n    }\n    if (c->read->eof) {\n        ngx_http_close_request(r, 0);\n        return;\n    }\n    ngx_http_finalize_connection(r);\n}']