Skip to content

Commit

Permalink
Best practices advices by @defanator on top of #104
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Zimmerle committed May 3, 2018
1 parent b81e6fd commit d1047ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ngx_http_modsecurity_body_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
u_char *data = chain->buf->pos;

msc_append_response_body(ctx->modsec_transaction, data, chain->buf->last - data);
msc_append_response_body(ctx->modsec_transaction, data,
ngx_buf_size(chain->buf));
ret = ngx_http_modsecurity_process_intervention(ctx->modsec_transaction, r);
if (ret > 0) {
return ngx_http_filter_finalize_request(r,
Expand Down
5 changes: 2 additions & 3 deletions src/ngx_http_modsecurity_pre_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)

dd("request body is ready to be processed");

ngx_chain_t *chain = r->request_body->bufs;

/**
* TODO: Speed up the analysis by sending chunk while they arrive.
*
Expand Down Expand Up @@ -161,12 +159,13 @@ ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)
dd("inspection request body in memory.");
}

ngx_chain_t *chain = r->request_body->bufs;
while (chain && !already_inspected)
{
u_char *data = chain->buf->pos;

msc_append_request_body(ctx->modsec_transaction, data,
chain->buf->last - data);
ngx_buf_size(chain->buf));

if (chain->buf->last_buf) {
break;
Expand Down

0 comments on commit d1047ea

Please sign in to comment.