php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61677 ext\zlib\tests\bug_52944.phpt fails
Submitted: 2012-04-09 11:22 UTC Modified: 2012-07-13 09:50 UTC
From: ab@php.net Assigned: ab (profile)
Status: Closed Package: Zlib related
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ab@php.net
New email:
PHP Version: OS:

 

 [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

Patches

61677.diff (last revision 2012-04-09 11:23 UTC by ab@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-09 11:23 UTC] ab@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:24 UTC] ab@php.net
zlib doesn't fail anymore on the bug 52944, so the test out is adopted
 [2012-04-16 12:11 UTC] ab@php.net
i've just realized, that the output is different on linux ... the thing needs probably more investigation
 [2012-05-23 15:19 UTC] ab@php.net
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.
 [2012-07-13 09:47 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=02b8362ec231edb5be2a4ff633ad609c70713131
Log: Fixed bug #61677 ext\zlib\tests\bug_52944.phpt fails
 [2012-07-13 09:50 UTC] ab@php.net
skip this test on windows until zlib dep was upgraded to 1.2.7
 [2012-07-13 09:50 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2014-10-07 23:23 UTC] stas@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=02b8362ec231edb5be2a4ff633ad609c70713131
Log: Fixed bug #61677 ext\zlib\tests\bug_52944.phpt fails
 [2014-10-07 23:34 UTC] stas@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=02b8362ec231edb5be2a4ff633ad609c70713131
Log: Fixed bug #61677 ext\zlib\tests\bug_52944.phpt fails
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC