Ticket #2058: ngx-catch-body.patch

File ngx-catch-body.patch, 1008 bytes (added by meelisroos@…, 6 years ago)

reproducer as patch to ngx_http_catch_body_filter_module

  • ngx_http_catch_body_filter_module.c

    old new  
    7272    u_char                      *p;
    7373    ngx_chain_t                 *cl;
    7474    ngx_http_catch_body_conf_t  *conf;
     75    int count = 0;
     76    int len;
    7577
    7678    conf = ngx_http_get_module_loc_conf(r, ngx_http_catch_body_filter_module);
    7779
     
    8587    for (cl = in; cl; cl = cl->next) {
    8688
    8789        p = cl->buf->pos;
     90        len = cl->buf->last - p;
     91        count += len;
    8892
    8993        for (p = cl->buf->pos; p < cl->buf->last; p++) {
    9094
     
    108112            }
    109113        }
    110114    }
     115    if (count == 0) {
     116                ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "catch body: wrong length");
     117                r->keepalive = 0;
     118                return NGX_HTTP_BAD_REQUEST;
     119    }
    111120
    112121    return ngx_http_next_request_body_filter(r, in);
    113122}