Skip to content

Fix GH-25678: exif_read_data() rejects valid WebP files without an EXIF chunk - #25679

Open
AceMedia wants to merge 1 commit into
php:PHP-8.6from
AceMedia:codex/gh25678-exif-webp-no-exif
Open

AceMedia wants to merge 1 commit into
php:PHP-8.6from
AceMedia:codex/gh25678-exif-webp-no-exif

Conversation

@AceMedia

Copy link
Copy Markdown

Fixes GH-25678. Targets PHP-8.6.

A WebP whose chunks are all well formed but which has no EXIF chunk was reported as "Invalid WebP file" and exif_read_data() returned false. A JPEG without EXIF returns FILE and COMPUTED. exif_scan_WEBP_header() now returns true after a clean walk of the chunk list. Truncated chunks, chunks larger than the declared RIFF size and an EXIF chunk under 8 bytes are still rejected.

ext/exif/tests/webp_chunk_layouts.phpt builds its own fixtures. It fails on the untouched branch for the no-EXIF cases and for a RIFF size too small to reach the EXIF chunk, and passes with the change. It also covers EXIF after the image data, the optional Exif\0\0 header, padding after an odd sized chunk, an oversized RIFF size, a truncated file and a tiny EXIF chunk, which already behaved correctly.

ext/exif passes 108 of 108 on a Linux x86-64 CLI build. I have not tested Windows.

Disclosure: I used an LLM to help investigate this, write the test and draft this description. I reviewed the change and the results myself.

… EXIF chunk

A WebP image whose chunks are all well formed but which carries no EXIF
chunk was reported as "Invalid WebP file", and exif_read_data() returned
false. A JPEG without EXIF returns the FILE and COMPUTED sections instead.
Treat a clean walk of the chunk list as a valid file without metadata and
keep rejecting truncated or oversized chunks.

Add a test covering files with and without an EXIF chunk, the optional Exif
header, padding after odd sized chunks and malformed layouts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant