Repository navigation
picture: refuse a JPEG whose decode stops before every pixel is written - #2759
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 10, 2026
ashhart
force-pushed
the
lead/jpeg-unwritten
branch
2 times, most recently
from
November 10, 2026 15:32
1519ab7 to
90b0841
Compare
TurboJPEG reports a fatal error as a warning when a warning came first, so a decode could return success over rows libjpeg never wrote. Decode over zeros and, on a warned decode, again over 0xFF: refuse unless both agree. Clean decodes keep their bytes.
ashhart
force-pushed
the
lead/jpeg-unwritten
branch
from
November 10, 2026 20:24
3a7b491 to
74447b8
Compare
ashhart
added a commit
that referenced
this pull request
Nov 10, 2026
ashhart
added a commit
that referenced
this pull request
Nov 10, 2026
ashhart
added a commit
to laudney/TensorFold
that referenced
this pull request
Nov 10, 2026
ashhart
added a commit
that referenced
this pull request
Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
A damaged JPEG could decode "successfully" with rows libjpeg never wrote. TurboJPEG 3 reports a fatal error as a warning when a warning came earlier in the same call, and the decoder took any warning as success, keeping an output buffer that hadn't been cleared. Such a file is now refused with the decoder's usual
error.Invalid, like any other undecodable image.Checks
zig build test-picture-hostwith the pinned libjpeg-turbo: new tests that four small damaged files are refused (they fail without the change) and that four warning-only files still decode to their expected pixels. Before: 29 pass, 1 skip, 1 fail; after: 30 pass, 1 skip (WebP, no library on the test machine).test-lfm2-load-host,test-codec-diagnostics-host: pass.Thanks to a community tester who reported this privately and sent a fix along the same lines.