reject out-of-range palette register in iff multipalette color map - #1327
Open
arib06 wants to merge 2 commits into
Open
reject out-of-range palette register in iff multipalette color map#1327arib06 wants to merge 2 commits into
arib06 wants to merge 2 commits into
Conversation
haraldk
previously approved these changes
Aug 28, 2026
haraldk
left a comment
Owner
There was a problem hiding this comment.
Thanks! Appreciate your fixes!
In this case it does fix the very specific issue of negative indexes. 👍🏻
However, I think it would provide a lot more value if we could also fix the issue as in the comment:
// TODO: Move validation to chunk (when reading)
Would you like to look into that as well?
Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
|
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 is fixed No open issue; hardening the IFF multipalette reader against a crafted PCHG chunk.
Why is this change proposed
MutableIndexColorModel.adjustColorMapvalidates palette change registers only against the upper bound (index >= rgbs.length) before writingrgbs[index], so a negative register slips through and writes out of bounds. ILBMPCHGBigLineChanges read a 32-bit register straight from the stream with a signedtoShort, so a register like0xfffebecomes-2and reachesadjustColorMapthroughgetColorModel/colorMapForRowwhile rendering, throwingArrayIndexOutOfBoundsExceptionout ofImageIO.readon a crafted IFF.What is changed
rgbs.lengthat the existing validation point, matching the current warn-and-ignore behaviour for out-of-range registers.MP_REG_IGNOREsentinel silently skipped so valid multipalette decoding is unchanged.PCHGChunkTestcovering a negative register (ignored) and an in-range register (applied).