[Zlib-devel] php->gzopen segfaults since zlib-1.2.3.5

Mark Adler madler at alumni.caltech.edu
Wed Jan 27 22:22:51 EST 2010


On Jan 27, 2010, at 12:48 PM, Török Edwin wrote:
> The culprit seems to be gzflush,

Thanks for the small test case.  I'm not sure how, but a line went missing in the source.  gzflush() isn't allowed when reading.  The patch below fixes it:

Mark


--- ../zlib-1.2.3.7/gzwrite.c	2010-01-18 12:18:27.000000000 -0800
+++ gzwrite.c	2010-01-27 19:19:52.000000000 -0800
@@ -435,7 +436,8 @@
     state = (gz_statep)file;
 
     /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE|| state->err != Z_OK)
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return Z_STREAM_ERROR;
 
     /* check flush parameter */
     if (flush < 0 || flush > Z_FINISH)





More information about the Zlib-devel mailing list