Fixed: flush libxml2 output buffer

This commit is contained in:
Breno Silva 2013-06-04 19:58:36 -07:00
parent df0b048254
commit 5cf5ff043a

View File

@ -1072,6 +1072,7 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
}
htmlDocContentDumpFormatOutput(output_buf, msr->crypto_html_tree, NULL, 0);
xmlOutputBufferFlush(output_buf);
#ifdef LIBXML2_NEW_BUFFER
@ -1090,7 +1091,6 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
}
msr->stream_output_length = xmlOutputBufferGetSize(output_buf);
//msr->stream_output_length = elts + msr->resbody_length;
msr->stream_output_data = (char *)malloc(msr->stream_output_length+1);
if (msr->stream_output_data == NULL) {
@ -1120,7 +1120,6 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
}
msr->stream_output_length = xmlOutputBufferGetSize(output_buf);
//msr->stream_output_length = elts + msr->resbody_length;
msr->stream_output_data = (char *)malloc(msr->stream_output_length+1);
if (msr->stream_output_data == NULL) {
@ -1163,8 +1162,8 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
}
memset(msr->stream_output_data, 0x0, msr->stream_output_length+1);
//memcpy(msr->stream_output_data, (char *)xmlBufferContent(output_buf->buffer), msr->stream_output_length);
memcpy(msr->stream_output_data, output_buf->buffer->content, msr->stream_output_length);
memcpy(msr->stream_output_data, (char *)xmlBufferContent(output_buf->buffer), msr->stream_output_length);
//memcpy(msr->stream_output_data, output_buf->buffer->content, msr->stream_output_length);
if (msr->txcfg->debuglog_level >= 4)
msr_log(msr, 4, "inject_hashed_response_body: Copying XML tree from CONTENT to stream buffer [%d] bytes.", msr->stream_output_length);
@ -1193,8 +1192,8 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
}
memset(msr->stream_output_data, 0x0, msr->stream_output_length+1);
//memcpy(msr->stream_output_data, (char *)xmlBufferContent(output_buf->conv), msr->stream_output_length);
memcpy(msr->stream_output_data, output_buf->conv->content, msr->stream_output_length);
memcpy(msr->stream_output_data, (char *)xmlBufferContent(output_buf->conv), msr->stream_output_length);
//memcpy(msr->stream_output_data, output_buf->conv->content, msr->stream_output_length);
if (msr->txcfg->debuglog_level >= 4)
msr_log(msr, 4, "inject_hashed_response_body: Copying XML tree from CONV to stream buffer [%d] bytes.", msr->stream_output_length);