Edit report at https://bugs.php.net/bug.php?id=61677&edit=1
ID: 61677 Comment by: a...@php.net Reported by: a...@php.net Summary: ext\zlib\tests\bug_52944.phpt fails Status: Open Type: Bug Package: Zlib related Operating System: all PHP Version: Irrelevant Block user comment: N Private report: N New Comment: What happens here is most likely a zlib issue. After a lot of debugging I came up with the snippet to look what happens if php is completely ommited (just quickly adopted some code from the net): ======================= START SNIPPET =================================== #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <zlib.h> #define CHUNK 0x4000 int main () { const char * file_name = "corrupted.gz"; FILE * file; z_stream strm = {0}; unsigned char in[CHUNK]; unsigned char out[CHUNK]; int status; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = in; strm.avail_in = 0; strm.next_out = out; status = inflateInit2(&strm, -15); if (0 > status) { fprintf(stderr, "inflateInit2(): %s\n", zError(status)); return 3; } file = fopen(file_name, "rb"); if (!file) { fprintf(stderr, "fopen(): %s\n", strerror(errno)); return 3; } while (1) { int bytes_read; bytes_read = fread(in, sizeof(char), sizeof(in), file); if (ferror(file)){ fprintf(stderr, "fread(): %s\n", strerror(errno)); return 3; } strm.avail_in = bytes_read; do { strm.avail_out = CHUNK; status = inflate(& strm, Z_NO_FLUSH); if (0 > status) { inflateEnd(&strm); fprintf(stderr, "inflate(): %s\n", zError(status)); return 1; } printf("%s", out); } while (strm.avail_out == 0); if (feof(file)) { inflateEnd(&strm); break; } } if (fclose(file)) { fprintf(stderr, "fclose(): %s\n", strerror(errno)); return 3; } return 0; } ======================= END SNIPPET ===================================== I've used the data from the original bug which is still available under http://188.40.74.4/corrupted.gz and then compiled it on windows cl inflate.c C:\php-sdk\php53\vc9\x86\deps\lib\zlib_a.lib "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcrt.lib" /I C:\php-sdk\php53\vc9\x86\deps\include and linux gcc -o inflate inflate.c -lz The result is pretty matching, the out on windows gives %Cë and on linux inflate(): data error So PHP. In both of my tests PHP reports zlib version of 1.2.5 . Despite this we could try to upgrade the zlib version for PHP on windows and see what happens. Previous Comments: ------------------------------------------------------------------------ [2012-04-16 12:11:12] a...@php.net i've just realized, that the output is different on linux ... the thing needs probably more investigation ------------------------------------------------------------------------ [2012-04-09 11:24:35] a...@php.net zlib doesn't fail anymore on the bug 52944, so the test out is adopted ------------------------------------------------------------------------ [2012-04-09 11:23:44] a...@php.net The following patch has been added/updated: Patch Name: 61677.diff Revision: 1333970624 URL: https://bugs.php.net/patch-display.php?bug=61677&patch=61677.diff&revision=1333970624 ------------------------------------------------------------------------ [2012-04-09 11:22:41] a...@php.net Description: ------------ Test diff: 001+ string(1) "%" 002+ string(1) "C" 001- string(0) "" 002- string(0) "" Expected result: ---------------- test pass Actual result: -------------- test fail ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61677&edit=1