Fix rastertohp heap-buffer-overread on planar KCMY/CMY input - #1671
Merged
michaelrsweet merged 1 commit intoAug 18, 2026
Merged
Conversation
luukvinke
force-pushed
the
fix_rastertohp_heap_disclosure
branch
from
August 18, 2026 13:12
ca17668 to
7907a02
Compare
Member
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.
Rastertohp (the HP PCL driver filter) reads past the end of its per-line plane buffer when processing a planar
KCMY/CMY CUPS Raster page, leaking heap data into the emitted PCL stream. This can be reproduced with the attached PoC. (attached as a text file)
kcmy1-planar-width64-height2.ras.txt
OutputLine() sized each color plane with the full single-channel row length,
(cupsWidth + 7) / 8 == cupsBytesPerLine, instead of the per-plane physical
row size, cupsBytesPerLine / NumPlanes. For planar KCMY/CMY input,
cupsBytesPerLine already packs all planes into one line, each plane being
only cupsBytesPerLine / NumPlanes bytes wide. At width 64 the last of the 4
planes reads [6, 14) of a 12-byte allocation — 2 bytes beyond the
cupsBytesPerLine + NumPlanes buffer.
In order to fix this, use bytes = cupsBytesPerLine / NumPlanes, the actual
per-plane row size. This matches the values used by the other rasterto*
filters, so output never extends beyond the supplied raster payload.
Fixes #1658