@@ -139,12 +139,14 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
139
139
if (rc == 0 ) {
140
140
modsecurity_request_body_retrieve_end (msr );
141
141
142
- bucket = apr_bucket_eos_create (f -> r -> connection -> bucket_alloc );
143
- if (bucket == NULL ) return APR_EGENERAL ;
144
- APR_BRIGADE_INSERT_TAIL (bb_out , bucket );
142
+ if (msr -> if_seen_eos ) {
143
+ bucket = apr_bucket_eos_create (f -> r -> connection -> bucket_alloc );
144
+ if (bucket == NULL ) return APR_EGENERAL ;
145
+ APR_BRIGADE_INSERT_TAIL (bb_out , bucket );
145
146
146
- if (msr -> txcfg -> debuglog_level >= 4 ) {
147
- msr_log (msr , 4 , "Input filter: Sent EOS." );
147
+ if (msr -> txcfg -> debuglog_level >= 4 ) {
148
+ msr_log (msr , 4 , "Input filter: Sent EOS." );
149
+ }
148
150
}
149
151
150
152
/* We're done */
@@ -164,7 +166,7 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
164
166
*/
165
167
apr_status_t read_request_body (modsec_rec * msr , char * * error_msg ) {
166
168
request_rec * r = msr -> r ;
167
- unsigned int seen_eos ;
169
+ unsigned int finished_reading ;
168
170
apr_bucket_brigade * bb_in ;
169
171
apr_bucket * bucket ;
170
172
@@ -193,7 +195,8 @@ apr_status_t read_request_body(modsec_rec *msr, char **error_msg) {
193
195
return -1 ;
194
196
}
195
197
196
- seen_eos = 0 ;
198
+ finished_reading = 0 ;
199
+ msr -> if_seen_eos = 0 ;
197
200
bb_in = apr_brigade_create (msr -> mp , r -> connection -> bucket_alloc );
198
201
if (bb_in == NULL ) return -1 ;
199
202
do {
@@ -283,6 +286,11 @@ apr_status_t read_request_body(modsec_rec *msr, char **error_msg) {
283
286
284
287
if (buflen != 0 ) {
285
288
int rcbs = modsecurity_request_body_store (msr , buf , buflen , error_msg );
289
+
290
+ if (msr -> reqbody_length > (apr_size_t )msr -> txcfg -> reqbody_limit && msr -> txcfg -> if_limit_action == REQUEST_BODY_LIMIT_ACTION_PARTIAL ) {
291
+ finished_reading = 1 ;
292
+ }
293
+
286
294
if (rcbs < 0 ) {
287
295
if (rcbs == -5 ) {
288
296
if ((msr -> txcfg -> is_enabled == MODSEC_ENABLED ) && (msr -> txcfg -> if_limit_action == REQUEST_BODY_LIMIT_ACTION_REJECT )) {
@@ -309,12 +317,13 @@ apr_status_t read_request_body(modsec_rec *msr, char **error_msg) {
309
317
}
310
318
311
319
if (APR_BUCKET_IS_EOS (bucket )) {
312
- seen_eos = 1 ;
320
+ finished_reading = 1 ;
321
+ msr -> if_seen_eos = 1 ;
313
322
}
314
323
}
315
324
316
325
apr_brigade_cleanup (bb_in );
317
- } while (!seen_eos );
326
+ } while (!finished_reading );
318
327
319
328
// TODO: Why ignore the return code here?
320
329
modsecurity_request_body_end (msr , error_msg );
0 commit comments