[php-src] PR #25982: Fix GH-25961: Reject truncated JPEG SOF headers
| From: | jlu-lujing | Date: | Tue, 01 Dec 2026 01:28:49 +0000 |
| Subject: | [php-src] PR #25982: Fix GH-25961: Reject truncated JPEG SOF headers | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41297@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25982
Author: jlu-lujing
A truncated JPEG SOF segment currently leaves
php_stream_getc() EOF in the unsigned
channel field, so getimagesize() and getimagesizefromstring() publish
UINT_MAX channels. Read the fixed six-byte SOF payload together, validate the declared
segment length, and return failure when any byte is missing.
The regression uses the minimal truncated header from the report. The whole image test directory
passes with the change.
Tests:
- New PHPT fails before the change and passes after it.
- ext/standard/tests/image: 33 passed, 8 skipped due to optional extensions omitted
from the minimal build, 0 failed.
> OpenAI Codex assisted with investigating the JPEG parser, preparing the focused code and
> regression test, and drafting this description. I reviewed and verified the resulting change
> locally.