Skip to content

Commit b8636a7

Browse files
gravagliFelipe Zimmerle
authored and
Felipe Zimmerle
committed
added "empy chunk" check
1 parent 9c51671 commit b8636a7

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

apache2/apache2_io.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
8585
return APR_EGENERAL;
8686
}
8787

88-
if (chunk && (!msr->txcfg->stream_inbody_inspection || (msr->txcfg->stream_inbody_inspection && msr->if_stream_changed == 0))) {
89-
/* Copy the data we received in the chunk */
90-
bucket = apr_bucket_heap_create(chunk->data, chunk->length, NULL,
91-
f->r->connection->bucket_alloc);
88+
if (chunk->length > 0) {
89+
if (chunk && (!msr->txcfg->stream_inbody_inspection || (msr->txcfg->stream_inbody_inspection && msr->if_stream_changed == 0))) {
90+
/* Copy the data we received in the chunk */
91+
bucket = apr_bucket_heap_create(chunk->data, chunk->length, NULL,
92+
f->r->connection->bucket_alloc);
9293

9394
#if 0
9495

@@ -107,33 +108,34 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
107108

108109
#endif
109110

110-
if (bucket == NULL) return APR_EGENERAL;
111-
APR_BRIGADE_INSERT_TAIL(bb_out, bucket);
111+
if (bucket == NULL) return APR_EGENERAL;
112+
APR_BRIGADE_INSERT_TAIL(bb_out, bucket);
112113

113-
if (msr->txcfg->debuglog_level >= 4) {
114-
msr_log(msr, 4, "Input filter: Forwarded %" APR_SIZE_T_FMT " bytes.", chunk->length);
115-
}
116-
} else if (msr->stream_input_data != NULL) {
114+
if (msr->txcfg->debuglog_level >= 4) {
115+
msr_log(msr, 4, "Input filter: Forwarded %" APR_SIZE_T_FMT " bytes.", chunk->length);
116+
}
117+
} else if (msr->stream_input_data != NULL) {
117118

118-
msr->if_stream_changed = 0;
119+
msr->if_stream_changed = 0;
119120

120-
bucket = apr_bucket_heap_create(msr->stream_input_data, msr->stream_input_length, NULL,
121-
f->r->connection->bucket_alloc);
121+
bucket = apr_bucket_heap_create(msr->stream_input_data, msr->stream_input_length, NULL,
122+
f->r->connection->bucket_alloc);
122123

123-
if (msr->txcfg->stream_inbody_inspection) {
124-
if(msr->stream_input_data != NULL) {
125-
free(msr->stream_input_data);
126-
msr->stream_input_data = NULL;
124+
if (msr->txcfg->stream_inbody_inspection) {
125+
if(msr->stream_input_data != NULL) {
126+
free(msr->stream_input_data);
127+
msr->stream_input_data = NULL;
128+
}
127129
}
128-
}
129130

130-
if (bucket == NULL) return APR_EGENERAL;
131-
APR_BRIGADE_INSERT_TAIL(bb_out, bucket);
131+
if (bucket == NULL) return APR_EGENERAL;
132+
APR_BRIGADE_INSERT_TAIL(bb_out, bucket);
132133

133-
if (msr->txcfg->debuglog_level >= 4) {
134-
msr_log(msr, 4, "Input stream filter: Forwarded %" APR_SIZE_T_FMT " bytes.", msr->stream_input_length);
135-
}
134+
if (msr->txcfg->debuglog_level >= 4) {
135+
msr_log(msr, 4, "Input stream filter: Forwarded %" APR_SIZE_T_FMT " bytes.", msr->stream_input_length);
136+
}
136137

138+
}
137139
}
138140

139141
if (rc == 0) {

0 commit comments

Comments
 (0)