|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-04-09 11:22 UTC] ab@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 Patches61677.diff (last revision 2012-04-09 11:23 UTC by ab@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
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.