From 5cf5ff043a366748adf31066576f0dc08e0cdcc5 Mon Sep 17 00:00:00 2001 From: Breno Silva Date: Tue, 4 Jun 2013 19:58:36 -0700 Subject: [PATCH] Fixed: flush libxml2 output buffer --- apache2/msc_crypt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apache2/msc_crypt.c b/apache2/msc_crypt.c index 09479695..cb61c879 100644 --- a/apache2/msc_crypt.c +++ b/apache2/msc_crypt.c @@ -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);