Skip to content

Refuse cut-short KTX textures instead of decoding them - #2895

Merged
abrignoni merged 2 commits into
mainfrom
fix/ktx-length-checks
Nov 25, 2026
Merged

abrignoni merged 2 commits into
mainfrom
fix/ktx-length-checks

Conversation

@abrignoni

@abrignoni abrignoni commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Cut-short KTX snapshots no longer become a full-size picture or stop the artifact. Fixes #2894 and #2890.

  • AAPL textures are accepted only at the two measured lengths (one block per 4x4 pixels, or the tiled surface plus one block), plus exactly the surface with HEAD word 12 = 1, which no file had. Short chunks and short Khronos textures are refused.
  • liblzfse.error now becomes ValueError. A made-up truncated LZFS snapshot used to leave App Snapshots with 0 rows; it is now left out with a log line.
  • 10,628 AAPL files in 24 corpus images all had a measured length. Row counts for the four KTX/ATX artifacts are unchanged on seven images.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

The PR appears safe to merge, with the previous test gap addressed and no new actionable issues found.

Summary

Refuses incomplete KTX textures before decoding and turns LZFSE failures into handled ValueError exceptions.

  • Texture readers reject incomplete KTX and AAPL image data.
  • Bad LZFSE textures now produce a handled decode failure.

Reviews (2) · Last reviewed commit: "Test the Khronos KTX length checks" · Reviewed by Greptile

The ASTC decoder returned a full-size picture with no error for short
data, and a cut tiled file was read in raster order. AAPL textures are
now accepted only at the two measured lengths (linear, or the tiled
surface plus one block) and at exactly the tiled surface when HEAD word
12 is 1, a length not seen in any file. A chunk shorter than it
declares is refused, and a Khronos KTX texture must hold the whole
image. liblzfse.error is turned into ValueError in both readers, so a
truncated LZFS snapshot no longer stops the artifact. App Snapshots and
Widgets leave it out with a log line; the ATX artifacts list it with a
warning.

Fixes #2894. Fixes #2890.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Valid and short KTX 1.1 fixtures, raw and Compression_APPLE. The LZFSE
compress call goes through one helper so lint stays clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni
abrignoni merged commit b3c837a into main Nov 25, 2026
31 checks passed
@abrignoni
abrignoni deleted the fix/ktx-length-checks branch November 25, 2026 19:38
abrignoni added a commit to charpy4n6/leapps-website that referenced this pull request Nov 25, 2026
Add #2895 to the list of changes, explain that a cut-short snapshot is
now refused (no row in App Snapshots or Widgets, a "Left out" log line,
a failed-decode row in Messages previews), rewrite the tiling steps to
the accepted sizes, re-pin the code link to the merge, and say which
changes a build needs for both zig-zags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Truncated KTX snapshots decode to a wrong picture with no warning

1 participant