Skip to content

Fix/exif offset hardening - #477

Merged
DichenZhang1 merged 3 commits into
mainfrom
fix/exif-offset-hardening
Sep 18, 2026
Merged

DichenZhang1 merged 3 commits into
mainfrom
fix/exif-offset-hardening

Conversation

@DichenZhang1

Copy link
Copy Markdown
Collaborator

Follow-up to #475:

  • Change marker_code parameter type from uint32_t to uint8_t in find_marker_payload_offset to match the 8-bit JPEG marker byte representation and avoid mixed-width comparisons.
  • Guard against signed long overflow when casting segment_payload_offset on very large input buffers.

- Avoid relying on libjpeg's saved-marker list to determine byte offsets of EXIF segments, as unsaved markers (e.g. COM, APP14, DQT) preceding EXIF cause offset miscalculation and bitstream desynchronization.
- Search source JPEG header directly for the extracted EXIF payload and validate segment bounds before splicing.
- Guard against repeated 0xFF marker fill bytes in the primary JPEG marker scanning loop in appendGainMap.
- Add comprehensive regression tests in JpegDecoderHelperTest covering marker ordering, duplicate EXIF segments, COM/APP14/DQT prefixes, and full API-4 recombination.

Fixes #474
Ref: PR #475
…rflow in find_marker_payload_offset

- Change marker_code parameter type from uint32_t to uint8_t in find_marker_payload_offset to match 8-bit JPEG marker byte representation and avoid mixed-width comparisons.
- Guard against signed long overflow when casting segment_payload_offset on very large input buffers.
@DichenZhang1
DichenZhang1 merged commit f3e3622 into main Sep 18, 2026
47 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