Bug 9014 - mod_deflate generates corrupted result at large data.
Summary: mod_deflate generates corrupted result at large data.
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_deflate (show other bugs)
Version: 2.0-HEAD
Hardware: Sun Solaris
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Depends on:
Reported: 2002-05-12 15:32 UTC by ASADA Kazuhisa
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description ASADA Kazuhisa 2002-05-12 15:32:54 UTC
mod_deflate module generates corrupted result with large data (over 200kbytes).
deflate_out_filter deflate input buckets into output bucket, but output buffer
information reset every input bucket, it means waste partial deflated data at
process next input bucket.
Output buffer must initialize before BRIGADE_FOREACH loop.

--- mod_deflate.c.org   Tue May  7 09:35:16 2002
+++ mod_deflate.c       Mon May 13 00:32:18 2002
@@ -328,4 +328,8 @@
+    /* initialize deflate output buffer */
+    ctx->stream.next_out = ctx->buffer;
+    ctx->stream.avail_out = c->bufferSize;
         const char *data;
@@ -437,6 +441,4 @@
                                                       * trust zlib */
         ctx->stream.avail_in = len;
-        ctx->stream.next_out = ctx->buffer;
-        ctx->stream.avail_out = c->bufferSize;
         while (ctx->stream.avail_in != 0) {
Comment 1 Justin Erenkrantz 2002-05-13 07:13:24 UTC

I was tracking this down last week, but I had to leave for WWDC and didn't
follow up.  Your patch is right and has been committed in revision 1.4 of
modules/filters/mod_deflate.c.  It will be included in the next release of
Apache 2.0!

Thanks for using Apache (and keep the patches coming)!
Comment 2 Bruno Wolff III 2002-05-31 03:12:49 UTC
I am still seeing these symptoms in the httpd-2.0_20020530221254.tar.gz
snapshot. The difference may be that for the files having problems
the output is generated by a cgi script and then fed through INCLUDES
and then DEFLATE. 50KB files work OK. 450KB files fail to be
uncompressed using lynx 2.5-dev, Netscape 4.08 and IE 5.?.
I am running this under linux 2.2.16 (Redhat) on a Athlon Tbird.
Comment 3 Bruno Wolff III 2002-06-01 15:45:36 UTC
I tested things a bit more and found that if I am just using the
DEFLATE filter things work OK. But when I use DEFLATE after INCLUDES
then they don't. I also tried just INCLUDES and the only
differences were the expected ones.
Comment 4 Jeff Trawick 2002-06-05 15:47:33 UTC
Is there any chance that you can provide a sample CGI script that 
generates the right include tags to causes mod_include to create 
a sequence of data that mod_deflate can't handle?

Comment 5 Bruno Wolff III 2002-06-05 16:18:03 UTC
A CGI-BIN script isn't needed to duplicate the problem.
A sample broken link is at:
Source to the actual files is available at:
The .txt files are sym links to the .html files. INCLUDES and DEFLATE
filters are run on .html files, but not on .txt files.
Comment 6 Cliff Woolley 2002-06-05 16:46:40 UTC
Justin Erenkrantz committed a patch to mod_deflate earlier today that might 
fix this problem.  Try out the CVS version of mod_deflate.c (rev 1.16) and see 
if that fixes your problem. 
Comment 7 Bruno Wolff III 2002-06-05 17:15:17 UTC
I tried 1.16 in a CVS snapshot from a few days ago and the problem
appears to be fixed. I will be removing the test files shortly.
Thanks for fixing this.