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

未關閉 適合新手
#25,960 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
c, php
領域
backend

研究方向

從ext/standard/image.c中約第627–643行的JPC解析器開始,這裡會讀取Csiz並處理元件描述符。檢查解析器如何讀取這些描述符並檢查邊界,接著尋找附近可執行的影像解析測試。完成標準是,這個截斷的碼流會使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 小時
30 天內合併 PR
111

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。