Bug #80953 [Opn->Fbk]: gzencode(): stream error

From: Date: Tue, 13 Apr 2021 11:14:39 +0000
Subject: Bug #80953 [Opn->Fbk]: gzencode(): stream error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233382@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80953&edit=1

 ID:                 80953
 Updated by:         cmb@php.net
 Reported by:        tessus@php.net
 Summary:            gzencode(): stream error
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Zlib related
 Operating System:   Linux
 PHP Version:        7.4.16
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> PHP Warning:  gzencode(): stream error in t.php on line 3

This is apparently caused by deflateInit2()[1] returning
Z_STREAM_ERROR.  The zlib manual[2] states:

| deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
| not enough memory, Z_STREAM_ERROR if a parameter is invalid (such
| as an invalid method), or Z_VERSION_ERROR if the zlib library
| version (zlib_version) is incompatible with the version assumed by
| the caller (ZLIB_VERSION).

Does zlib_version() match ZLIB_VERSION for you?

[1] <https://github.com/php/php-src/blob/php-7.4.16/ext/zlib/zlib.c#L346>
[2] <https://zlib.net/manual.html>


Previous Comments:
------------------------------------------------------------------------
[2021-04-12 17:49:32] tessus@php.net

Description:
------------
I've tested it with PHP 7.4.15 and PHP 7.4.16.

I get errors with zlib related functions. e.g. for the test script below, I get the following
warning, which should be an error in the first place, because the resulting file is invalid.

PHP Warning:  gzencode(): stream error in t.php on line 3

It happens with cli and php-fpm. I do have read/write access to the directory where the file
bigfile.txt is located.

I've tested this with 7.3.27 and it works without issues. I compile PHP myself and there were
no errors in config.log, nor during compilation. configure stated for both PHP releases that zlib
was found and ok to use.

Test script:
---------------
<?php
$data = implode("", file("bigfile.txt"));
$gzdata = gzencode($data, 9);
$fp = fopen("bigfile.txt.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
?>

Expected result:
----------------
The file should be compressed and the result should be a valid bigfile.txt.gz

Actual result:
--------------
A file bigfile.txt.gz is created with 0 bytes.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80953&edit=1


Thread (25 messages)

« previous php.bugs (#233382) next »