@@ -77,15 +77,16 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
7777 }
7878 }
7979
80- rc = modsecurity_request_body_retrieve (msr , & chunk , (unsigned int )nbytes , & my_error_msg );
81- if (rc == -1 ) {
80+ do {
81+ rc = modsecurity_request_body_retrieve (msr , & chunk , (unsigned int )nbytes , & my_error_msg );
82+ if (rc == -1 ) {
8283 if (my_error_msg != NULL ) {
8384 msr_log (msr , 1 , "%s" , my_error_msg );
8485 }
8586 return APR_EGENERAL ;
86- }
87+ }
8788
88- if (chunk && (!msr -> txcfg -> stream_inbody_inspection || (msr -> txcfg -> stream_inbody_inspection && msr -> if_stream_changed == 0 ))) {
89+ if (chunk && (!msr -> txcfg -> stream_inbody_inspection || (msr -> txcfg -> stream_inbody_inspection && msr -> if_stream_changed == 0 ))) {
8990 /* Copy the data we received in the chunk */
9091 bucket = apr_bucket_heap_create (chunk -> data , chunk -> length , NULL ,
9192 f -> r -> connection -> bucket_alloc );
@@ -113,7 +114,7 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
113114 if (msr -> txcfg -> debuglog_level >= 4 ) {
114115 msr_log (msr , 4 , "Input filter: Forwarded %" APR_SIZE_T_FMT " bytes." , chunk -> length );
115116 }
116- } else if (msr -> stream_input_data != NULL ) {
117+ } else if (msr -> stream_input_data != NULL ) {
117118
118119 msr -> if_stream_changed = 0 ;
119120
@@ -134,26 +135,26 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
134135 msr_log (msr , 4 , "Input stream filter: Forwarded %" APR_SIZE_T_FMT " bytes." , msr -> stream_input_length );
135136 }
136137
137- }
138+ }
138139
139- if (rc == 0 ) {
140- modsecurity_request_body_retrieve_end (msr );
140+ } while (rc != 0 );
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+ modsecurity_request_body_retrieve_end (msr );
145143
146- if ( msr -> txcfg -> debuglog_level >= 4 ) {
147- msr_log ( msr , 4 , "Input filter: Sent EOS." ) ;
148- }
144+ bucket = apr_bucket_eos_create ( f -> r -> connection -> bucket_alloc );
145+ if ( bucket == NULL ) return APR_EGENERAL ;
146+ APR_BRIGADE_INSERT_TAIL ( bb_out , bucket );
149147
150- /* We're done */
151- msr -> if_status = IF_STATUS_COMPLETE ;
152- ap_remove_input_filter ( f );
148+ if ( msr -> txcfg -> debuglog_level >= 4 ) {
149+ msr_log ( msr , 4 , "Input filter: Sent EOS." ) ;
150+ }
153151
154- if (msr -> txcfg -> debuglog_level >= 4 ) {
155- msr_log (msr , 4 , "Input filter: Input forwarding complete." );
156- }
152+ /* We're done */
153+ msr -> if_status = IF_STATUS_COMPLETE ;
154+ ap_remove_input_filter (f );
155+
156+ if (msr -> txcfg -> debuglog_level >= 4 ) {
157+ msr_log (msr , 4 , "Input filter: Input forwarding complete." );
157158 }
158159
159160 return APR_SUCCESS ;
0 commit comments