php / php/php-src

gzfile and readgzfile no longer identify corrupted gzip data

オープン
#21,376 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Extension: zlib Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。