getimagesize(): JPEG 2000 Csiz is accepted without component descriptors

オープン 初心者向け
#25,960 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, php
領域
backend

調査の方向性

ext/standard/image.cの627~643行付近にあるJPCパーサーから始めます。ここではCsizを読み取り、コンポーネント記述子を処理しています。パーサーがこれらの記述子をどのように読み取り、範囲をチェックするかを確認し、近くにある実行可能な画像解析テストを探してください。この切り詰められたcodestreamによってgetimagesizefromstring()がfalseを返すようになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug Status: Needs Triage
Description

The following code:

<?php
$jpc = "\xFF\x4F\xFF\x51"
     . pack('nn', 47, 0)
     . pack('NN', 1, 1)
     . str_repeat("\0", 24)
     . pack('n', 3);
var_dump(getimagesizefromstring($jpc));

Resulted in this output:

array(8) {
  [0]=>
  int(1)
  [1]=>
  int(1)
  [2]=>
  int(9)
  [3]=>
  string(20) "width="1" height="1""
  ["channels"]=>
  int(3)
  ["mime"]=>
  string(24) "application/octet-stream"
  ["width_unit"]=>
  string(2) "px"
  ["height_unit"]=>
  string(2) "px"
}

But I expected this output instead:

bool(false)

The JPC parser reads Csiz at ext/standard/image.c:627, then loops over that count at line 635 without requiring 3 * Csiz available descriptor bytes or checking the reads at lines 636-643. Since Csiz = 3 requires nine component-descriptor bytes, this truncated codestream must be rejected instead of returning three channels.

PHP Version
PHP 8.7.0-dev (cli) (built: Nov 29 2026 03:42:09) (NTS)
Copyright © The PHP Group and Contributors
Zend Engine v4.7.0-dev, Copyright © Zend by Perforce
    with Zend OPcache v8.7.0-dev, Copyright ©, by Zend by Perforce
Operating System

Ubuntu 24.04.5 LTS

主要言語
C
スター
41.9k
フォーク
8.5k
平均マージ
2日 17時間
マージ済み PR(30日)
111

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

php/php-src のほかの issue

php/php-src の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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