Skip to content

Fix rastertohp heap-buffer-overread on planar KCMY/CMY input - #1671

Merged
michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
luukvinke:fix_rastertohp_heap_disclosure
Aug 18, 2026
Merged

Fix rastertohp heap-buffer-overread on planar KCMY/CMY input#1671
michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
luukvinke:fix_rastertohp_heap_disclosure

Conversation

@luukvinke

Copy link
Copy Markdown
Contributor

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

@luukvinke
luukvinke force-pushed the fix_rastertohp_heap_disclosure branch from ca17668 to 7907a02 Compare August 18, 2026 13:12

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaelrsweet michaelrsweet self-assigned this Aug 18, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Aug 18, 2026
@michaelrsweet michaelrsweet added this to the v2.4.x milestone Aug 18, 2026
@michaelrsweet
michaelrsweet merged commit 0680fa5 into OpenPrinting:master Aug 18, 2026
@michaelrsweet

Copy link
Copy Markdown
Member

[2.4.x 6aecf6e] Fix potential raster length issue in rastertohp driver (Issue #1658)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUPS rastertohp planar KCMY heap disclosure

2 participants