Skip to content

Never crash: Check raw data size before allocating in PEF, TIFF tiles and ARW6 (#1512) - #1776

Merged
echelon merged 1 commit into
storytold:mainfrom
endthestart:fix/1512-alloc-before-checks
Oct 15, 2026
Merged

echelon merged 1 commit into
storytold:mainfrom
endthestart:fix/1512-alloc-before-checks

Conversation

@endthestart

Copy link
Copy Markdown
Contributor

Three places allocated the full picture before checking the data could fill it. A compressed PEF now has to have at least one bit per sample, since every Huffman code is at least that long. An uncompressed TIFF tile or strip holding less than 1/64 of what its samples need is refused (short ones are still padded with zeros like before). ARW6 collects the tile results and stops at the first failed tile before allocating the mosaic. So a few KB can't ask for gigabytes anymore.

I added tests for the PEF and tile cases, for example a 4 KB PEF stream claiming 30000 x 30000 is refused right away. The ARW6 one only moves the error check before the allocation, and the raws in the corpus still decode the same. Thanks!

Fixes #1512

… and ARW6 (storytold#1512)

A compressed PEF too short for its size, an uncompressed tile claiming far more samples than it holds, and an ARW6 with a failed tile now get refused before the big buffer is allocated.
bogusyogi added a commit to Orthic-Labs/ember that referenced this pull request Oct 15, 2026
… and ARW6 (storytold#1512) (upstream storytold#1776)

Applied from storytold/lightcraft PR storytold#1776 (open upstream, not yet merged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon
echelon merged commit 2c4390e into storytold:main Oct 15, 2026
@echelon

echelon commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thank you @endthestart! This landed on main in integration batch 36 (#1843).

If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RAW allocation guards miss nominal TIFF tiles, compressed PEF, and failed ARW6 tiles

2 participants