Repository navigation
IiqDecoder: bounds-check row in bad-pixel defect handling - #994
Merged
LebedevRI merged 2 commits intoOct 8, 2026
Merged
Conversation
PR darktable-org#965 added a bounds check for `col` in the bad-column path of correctSensorDefects(), but the bad-pixel path (case 129) in the same switch validates `col` and not `row`. An attacker-controlled row value (up to 65535) flows via mBadPixelPositions into transferBadPixelsToMap, which writes mBadPixelMap[(pitch * pos_y) + (pos_x >> 3)] guarded only by asserts — a heap OOB write in release builds.
LebedevRI
reviewed
Oct 8, 2026
Contributor
Author
|
Done: moved the bounds check into |
Member
|
@kalt2212 thank you! |
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.
Summary
Fixes a heap-buffer-overflow WRITE in the IIQ decoder's bad-pixel defect handling.
Details
PR #965 ("bounds-check col before correctBadColumn") covered the bad-column path but missed the bad-pixel path (
case 129) in the same switch ofcorrectSensorDefects(). Both are fed by the same attacker-controlled tag (IIQ 0x400 "Sensor Defects"). The code validatescolbut notrow(uint16_t, up to 65535).The unchecked
rowflows viamBadPixelPositionsintotransferBadPixelsToMap()(RawImage.cpp), which writesmBadPixelMap[(pitch * pos_y) + (pos_x >> 3)]guarded only byasserts — a heap OOB write in release builds, abort/DoS with asserts. Reachable by default (interpolateBadPixels=true).PoC with ASan: exact sink replica,
row=65535→ SEGV on WRITE.Testing
ASan PoC confirms the OOB write before the fix; clean after.
AI tool use disclosure: AI was used in part for code audit and patch drafting.