Repository navigation
reject out-of-range marker codes in jpegli_save_markers - #255
Open
rootvector2 wants to merge 1 commit into
Open
rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
This branch has not been deployed
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
jpegli_save_markersonly rejectsmarker_code < 0xe0before writingm->markers_to_save_[marker_code - 0xe0], auint8_t[32]that covers0xe0..0xff. Anymarker_code > 0xffpasses the guard and writes a byte at an attacker-chosen positive offset past the array in the heap-allocatedjpeg_decomp_master(ASan reports a heap-buffer-overflow WRITE of size 1 formarker_code = 0x10000). Reachable through both this entry point and the libjpeg-compatiblejpeg_save_markerswrapper.Found by comparing this setter against its sibling
jpegli_set_marker_processorandjpegli_write_m_header, which both bound the code from above, and libjpeg'sjdmarker.c, which rejects unknown codes withJERR_UNKNOWN_MARKER. The fix adds the missing upper bound at the array size, so every code that was previously in range is still accepted. Added aDecoderErrorHandlingTestthat passes0x100and expects a clean error; it fails before the fix and passes after.Pull Request Checklist
./ci.sh lintfor automatic code formatting.