gzfile and readgzfile no longer identify corrupted gzip data
未关闭
还没有人认领这个 Issue。
Bug
Extension: zlib
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
Using this (invalid) gzip file: corrupt.txt.gz for testing below.
Just for completion: this is what happens using zcat/gzip - it can't decode it and thinks it's encrypted. It's not, it's just garbage.
$ zcat corrupt.txt.gz gzip: corrupt.txt.gz is encrypted -- not supported
The following code:
<?php
var_dump(gzfile("corrupt.txt.gz"));
Resulted in this output:
array(2) {
[0]=>
string(8) "x�� U"
[1]=>
string(6) "I-.��"
}
But I expected this output instead:
array(0) {
}
Running the same code with PHP < 8.5.3 (including 8.5.2) will result in the expected empty array.
The same issue exists when using readgzfile(): all older versions will return -1 while 8.5.3 returns binary data.
PHP Version
PHP 8.5.3 (cli) (built: Feb 12 2026 16:29:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Xdebug v3.5.1, Copyright (c) 2002-2026, by Derick Rethans
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
Operating System
ArchLinux
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在 PHP 8.5.2 和 8.5.3 上使用 gzfile() 和 readgzfile() 重现所提供的 corrupt.txt.gz 案例。跟踪这些函数使用的 gzip 处理过程,并将损坏数据的结果与预期的空数组和 -1 返回值进行比较;当两个函数都像之前一样拒绝无效流时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100