src/http/ngx_http_upstream.c:2382: error: Integer Overflow L2
  ([0, `r->main->count` + 3] - 1):unsigned32 by call to `ngx_http_upstream_finalize_request`.

src/http/ngx_http_upstream.c:2349:1: Parameter `r->main->count`
2347. 
2348. 
2349. static ngx_int_t
      ^
2350. ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
2351. {

src/http/ngx_http_upstream.c:2382:13: Call
2380.             }
2381. 
2382.             ngx_http_upstream_finalize_request(r, u, rc);
                  ^
2383.             return NGX_OK;
2384.         }

src/http/ngx_http_upstream.c:4163:1: Parameter `r->main->count`
  4161. 
  4162. 
  4163. static void
        ^
  4164. ngx_http_upstream_finalize_request(ngx_http_request_t *r,
  4165.     ngx_http_upstream_t *u, ngx_int_t rc)

src/http/ngx_http_upstream.c:4174:9: Call
  4172.     if (u->cleanup == NULL) {
  4173.         /* the request was already finalized */
  4174.         ngx_http_finalize_request(r, NGX_DONE);
                ^
  4175.         return;
  4176.     }

src/http/ngx_http_request.c:2292:1: Parameter `r->main->count`
    2290. 
    2291. 
    2292. void
          ^
    2293. ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
    2294. {

src/http/ngx_http_request.c:2473:9: Call
    2471.     }
    2472. 
    2473.     if (ngx_http_post_action(r) == NGX_OK) {
                  ^
    2474.         return;
    2475.     }

src/http/ngx_http_request.c:3376:1: <LHS trace>
3374. 
3375. 
3376. static ngx_int_t
      ^
3377. ngx_http_post_action(ngx_http_request_t *r)
3378. {

src/http/ngx_http_request.c:3376:1: Parameter `r->main->count`
      3374. 
      3375. 
      3376. static ngx_int_t
            ^
      3377. ngx_http_post_action(ngx_http_request_t *r)
      3378. {

src/http/ngx_http_request.c:3394:5: Binary operation: ([0, r->main->count + 3] - 1):unsigned32 by call to `ngx_http_upstream_finalize_request` 
      3392.                    "post action: \"%V\"", &clcf->post_action);
      3393. 
      3394.     r->main->count--;
                ^
      3395. 
      3396.     r->http_version = NGX_HTTP_VERSION_9;

static ngx_int_t
ngx_http_post_action(ngx_http_request_t *r)
{
    ngx_http_core_loc_conf_t  *clcf;
    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
    if (clcf->post_action.data == NULL) {
        return NGX_DECLINED;
    }
    if (r->post_action && r->uri_changes == 0) {
        return NGX_DECLINED;
    }
    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                   "post action: \"%V\"", &clcf->post_action);
    r->main->count--;
    r->http_version = NGX_HTTP_VERSION_9;
    r->header_only = 1;
    r->post_action = 1;
    r->read_event_handler = ngx_http_block_reading;
    if (clcf->post_action.data[0] == '/') {
        ngx_http_internal_redirect(r, &clcf->post_action, NULL);
    } else {
        ngx_http_named_location(r, &clcf->post_action);
    }
    return NGX_OK;
}
['static ngx_int_t\nngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)\n{\n    ngx_uint_t                 status;\n    ngx_http_upstream_next_t  *un;\n    status = u->headers_in.status_n;\n    for (un = ngx_http_upstream_next_errors; un->status; un++) {\n        if (status != un->status) {\n            continue;\n        }\n        if (u->peer.tries > 1 && (u->conf->next_upstream & un->mask)) {\n            ngx_http_upstream_next(r, u, un->mask);\n            return NGX_OK;\n        }\n#if (NGX_HTTP_CACHE)\n        if (u->cache_status == NGX_HTTP_CACHE_EXPIRED\n            && ((u->conf->cache_use_stale & un->mask) || r->cache->stale_error))\n        {\n            ngx_int_t  rc;\n            rc = u->reinit_request(r);\n            if (rc == NGX_OK) {\n                u->cache_status = NGX_HTTP_CACHE_STALE;\n                rc = ngx_http_upstream_cache_send(r, u);\n            }\n            ngx_http_upstream_finalize_request(r, u, rc);\n            return NGX_OK;\n        }\n#endif\n    }\n#if (NGX_HTTP_CACHE)\n    if (status == NGX_HTTP_NOT_MODIFIED\n        && u->cache_status == NGX_HTTP_CACHE_EXPIRED\n        && u->conf->cache_revalidate)\n    {\n        time_t     now, valid, updating, error;\n        ngx_int_t  rc;\n        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http upstream not modified");\n        now = ngx_time();\n        valid = r->cache->valid_sec;\n        updating = r->cache->updating_sec;\n        error = r->cache->error_sec;\n        rc = u->reinit_request(r);\n        if (rc != NGX_OK) {\n            ngx_http_upstream_finalize_request(r, u, rc);\n            return NGX_OK;\n        }\n        u->cache_status = NGX_HTTP_CACHE_REVALIDATED;\n        rc = ngx_http_upstream_cache_send(r, u);\n        if (valid == 0) {\n            valid = r->cache->valid_sec;\n            updating = r->cache->updating_sec;\n            error = r->cache->error_sec;\n        }\n        if (valid == 0) {\n            valid = ngx_http_file_cache_valid(u->conf->cache_valid,\n                                              u->headers_in.status_n);\n            if (valid) {\n                valid = now + valid;\n            }\n        }\n        if (valid) {\n            r->cache->valid_sec = valid;\n            r->cache->updating_sec = updating;\n            r->cache->error_sec = error;\n            r->cache->date = now;\n            ngx_http_file_cache_update_header(r);\n        }\n        ngx_http_upstream_finalize_request(r, u, rc);\n        return NGX_OK;\n    }\n#endif\n    return NGX_DECLINED;\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_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "finalize http upstream request: %i", rc);\n    if (u->cleanup == NULL) {\n        ngx_http_finalize_request(r, NGX_DONE);\n        return;\n    }\n    *u->cleanup = NULL;\n    u->cleanup = NULL;\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_time) {\n        u->state->response_time = ngx_current_msec - u->state->response_time;\n        if (u->pipe && u->pipe->read_length) {\n            u->state->bytes_received += u->pipe->read_length\n                                        - u->pipe->preread_size;\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    r->read_event_handler = ngx_http_block_reading;\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        || (u->pipe && u->pipe->downstream_error))\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: %i, \\"%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        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        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n        if (r->background) {\n            if (!r->logged) {\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            ngx_http_finalize_connection(r);\n            return;\n        }\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            if (!r->logged) {\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) {\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->read_event_handler = ngx_http_block_reading;\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}', 'static ngx_int_t\nngx_http_post_action(ngx_http_request_t *r)\n{\n    ngx_http_core_loc_conf_t  *clcf;\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->post_action.data == NULL) {\n        return NGX_DECLINED;\n    }\n    if (r->post_action && r->uri_changes == 0) {\n        return NGX_DECLINED;\n    }\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "post action: \\"%V\\"", &clcf->post_action);\n    r->main->count--;\n    r->http_version = NGX_HTTP_VERSION_9;\n    r->header_only = 1;\n    r->post_action = 1;\n    r->read_event_handler = ngx_http_block_reading;\n    if (clcf->post_action.data[0] == \'/\') {\n        ngx_http_internal_redirect(r, &clcf->post_action, NULL);\n    } else {\n        ngx_http_named_location(r, &clcf->post_action);\n    }\n    return NGX_OK;\n}']