Skip to content

Commit d1047ea

Browse files
author
Felipe Zimmerle
committed
Best practices advices by @defanator on top of #104
1 parent b81e6fd commit d1047ea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: src/ngx_http_modsecurity_body_filter.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
152152
{
153153
u_char *data = chain->buf->pos;
154154

155-
msc_append_response_body(ctx->modsec_transaction, data, chain->buf->last - data);
155+
msc_append_response_body(ctx->modsec_transaction, data,
156+
ngx_buf_size(chain->buf));
156157
ret = ngx_http_modsecurity_process_intervention(ctx->modsec_transaction, r);
157158
if (ret > 0) {
158159
return ngx_http_filter_finalize_request(r,

Diff for: src/ngx_http_modsecurity_pre_access.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)
131131

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

134-
ngx_chain_t *chain = r->request_body->bufs;
135-
136134
/**
137135
* TODO: Speed up the analysis by sending chunk while they arrive.
138136
*
@@ -161,12 +159,13 @@ ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)
161159
dd("inspection request body in memory.");
162160
}
163161

162+
ngx_chain_t *chain = r->request_body->bufs;
164163
while (chain && !already_inspected)
165164
{
166165
u_char *data = chain->buf->pos;
167166

168167
msc_append_request_body(ctx->modsec_transaction, data,
169-
chain->buf->last - data);
168+
ngx_buf_size(chain->buf));
170169

171170
if (chain->buf->last_buf) {
172171
break;

0 commit comments

Comments
 (0)