CVE-2024-28584 - Fix NULL pointer dereference in JPEG2000 loader - #53
Merged
Conversation
opj_read_header() can report success while still leaving *image NULL for some malformed J2K/JP2 codestreams. Neither PluginJ2K.cpp nor PluginJP2.cpp checked for this before passing image into opj_decode() or J2KImageToFIBITMAP(), which immediately dereferences image->numcomps. Add the missing NULL check right after opj_read_header() in both loaders (the true point of failure, covering both the header-only and full-decode paths), plus a defense-in-depth guard in J2KImageToFIBITMAP() itself since it's called from both plugins. CWE-476 (NULL Pointer Dereference) Fixes: CVE-2024-28584
The previous commit's edits were re-serialized as UTF-8, corrupting each file's original ISO-8859-1 "Hervé Drolon" byte sequence into a replacement character. Restore it by converting the original files to UTF-8 properly rather than accidentally.
danoli3
force-pushed
the
fix/j2k-null-image-deref
branch
from
August 16, 2026 08:28
708ddd9 to
fcb9ba0
Compare
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.
opj_read_header()can report success while leavingimageNULL on malformed J2K/JP2 codestreams. Neither loader checked before passing it intoopj_decode()/J2KImageToFIBITMAP(), which dereferencesimage->numcomps— a crash on a crafted file.Adds the missing NULL check right after
opj_read_header()in bothPluginJ2K.cppandPluginJP2.cpp, plus a defense-in-depth guard insideJ2KImageToFIBITMAP()itself since both plugins call it.Fixes: CVE-2024-28584