Skip to content

CVE-2024-28584 - Fix NULL pointer dereference in JPEG2000 loader - #53

Merged
danoli3 merged 2 commits into
masterfrom
fix/j2k-null-image-deref
Aug 16, 2026
Merged

CVE-2024-28584 - Fix NULL pointer dereference in JPEG2000 loader#53
danoli3 merged 2 commits into
masterfrom
fix/j2k-null-image-deref

Conversation

@danoli3

@danoli3 danoli3 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

opj_read_header() can report success while leaving image NULL on malformed J2K/JP2 codestreams. Neither loader checked before passing it into opj_decode() / J2KImageToFIBITMAP(), which dereferences image->numcomps — a crash on a crafted file.

Adds the missing NULL check right after opj_read_header() in both PluginJ2K.cpp and PluginJP2.cpp, plus a defense-in-depth guard inside J2KImageToFIBITMAP() itself since both plugins call it.

CVE Link
CVE-2024-28584 https://nvd.nist.gov/vuln/detail/CVE-2024-28584

Fixes: CVE-2024-28584

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
danoli3 force-pushed the fix/j2k-null-image-deref branch from 708ddd9 to fcb9ba0 Compare August 16, 2026 08:28
@danoli3
danoli3 merged commit 79a69bc into master Aug 16, 2026
36 checks passed
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.

1 participant