Fix/jpeg metadata marker bounds#5174
Open
ssh4net wants to merge 5 commits intoAcademySoftwareFoundation:mainfrom
Open
Fix/jpeg metadata marker bounds#5174ssh4net wants to merge 5 commits intoAcademySoftwareFoundation:mainfrom
ssh4net wants to merge 5 commits intoAcademySoftwareFoundation:mainfrom
Conversation
avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was deprecated for couple years Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
lgritz
reviewed
Apr 30, 2026
Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
6a3d866 to
756ee90
Compare
lgritz
reviewed
Apr 30, 2026
|
|
||
|
|
||
| def iconvert_to_null(filename, success_marker): | ||
| output = filename.rsplit(".", 1)[0] + ".null" |
Collaborator
There was a problem hiding this comment.
Since null files never get written, there is not a reason to carefully construct the filename based on the input, just always call it "out.null" and be done with it.
I don't think you need the iconvert_to_null function at all. I would modify runtest.py's iconvert() function to take a new optional argument success_message and if it's non-empty, have it append "&& echo" + success_message (much in the way that it appends || true if you set failureok), then for the test you can just say
command += iconvert("foo.jpg out.null", successmessage="foo-ok")
lgritz
requested changes
Apr 30, 2026
Collaborator
lgritz
left a comment
There was a problem hiding this comment.
LGTM.
I made a suggestion for simplifying the test logic that boils down to:
- 2-line extension to runtest.py's
iconvertfunction. - No custom logic in this one test directory's run.py
- Just use
command += iconvert(...)with the new option
Other than that, this is ready to go, thanks for the fix.
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.
Description
Fixes bounds checks for malformed JPEG APP1 Exif and APP2 ICC metadata
markers.
Before this change, APP1 markers were treated as Exif when they started with
"Exif"and had at least 4 bytes. The reader then skipped 6 bytes for theExif\0\0prefix, so short payloads such asExiforExif\0could advancepast the saved marker buffer and underflow the remaining length passed to the
Exif parser.
The APP2 ICC path also used
strcmp()on raw marker bytes before proving themarker was long enough or NUL-terminated. Short APP2 markers could therefore be
read past the saved marker buffer, and the code later accessed sequence bytes
and subtracted
ICC_HEADER_SIZEwithout first checking the marker length.This is reachable by normal OpenImageIO image-open paths, including tools such
as
iinfo,iconvert, andoiiotool, when opening a malformed JPEG.The fix adds bounded marker-prefix helpers:
Exif\0\0prefix is present.ICC_HEADER_SIZEbytesand matches
ICC_PROFILE\0using bounded comparison.Tests
Added coverage to
testsuite/jpeg-corruptfor short APP1/APP2 metadatamarkers:
Validated locally with:
ctest --test-dir build-jpeg-only -R '^jpeg-corrupt$' --output-on-failureChecklist:
and if I used AI coding assistants, I have an `Assisted-by: Codex GPT 5.5xHigh
line in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.