@@ -139,12 +139,14 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
139139if (rc == 0 ) {
140140modsecurity_request_body_retrieve_end (msr );
141141
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 );
145146
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+ }
148150 }
149151
150152/* We're done */
@@ -164,7 +166,7 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
164166 */
165167apr_status_t read_request_body (modsec_rec * msr ,char * * error_msg ) {
166168request_rec * r = msr -> r ;
167- unsignedint seen_eos ;
169+ unsignedint finished_reading ;
168170apr_bucket_brigade * bb_in ;
169171apr_bucket * bucket ;
170172
@@ -193,7 +195,8 @@ apr_status_t read_request_body(modsec_rec *msr, char **error_msg) {
193195return -1 ;
194196 }
195197
196- seen_eos = 0 ;
198+ finished_reading = 0 ;
199+ msr -> if_seen_eos = 0 ;
197200bb_in = apr_brigade_create (msr -> mp ,r -> connection -> bucket_alloc );
198201if (bb_in == NULL )return -1 ;
199202do {
@@ -283,6 +286,11 @@ apr_status_t read_request_body(modsec_rec *msr, char **error_msg) {
283286
284287if (buflen != 0 ) {
285288int 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+
286294if (rcbs < 0 ) {
287295if (rcbs == -5 ) {
288296if ((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) {
309317 }
310318
311319if (APR_BUCKET_IS_EOS (bucket )) {
312- seen_eos = 1 ;
320+ finished_reading = 1 ;
321+ msr -> if_seen_eos = 1 ;
313322 }
314323 }
315324
316325apr_brigade_cleanup (bb_in );
317- }while (!seen_eos );
326+ }while (!finished_reading );
318327
319328// TODO: Why ignore the return code here?
320329modsecurity_request_body_end (msr ,error_msg );