Skip to content

rastertoescpx: reject a negative or oversized cupsRowFeed - #810

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
Sharadhi-v98:rastertoescpx-row-feed-bounds
Nov 20, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
Sharadhi-v98:rastertoescpx-row-feed-bounds

Conversation

@Sharadhi-v98

Copy link
Copy Markdown
Contributor
  1. StartPage() in rastertoescpx copies cupsRowFeed from the page header into the int DotRowFeed and only checks it for 0. A raw raster job with cupsRowCount > 1 and cupsRowFeed >= 0x80000000 makes it negative, so subrow = (subrow + DotRowFeed) % modrow in the initial band fill goes negative and the loop reads and writes DotBands[subrow][plane] before the start of the array. With cupsRowCount 2, cupsRowStep 264 (modrow 128) and cupsRowFeed 0xFFFFFF38, subrow becomes -73 and the band pointers are written about 4 KB before DotBands. A feed close to INT_MAX overflows the same sum.
  2. The geometry check added for DotRowStep/DotColStep doesn't cover the feed, and the CUPS raster reader doesn't validate cupsRowFeed. A negative feed or one above INT_MAX / (modrow + 1) is now rejected next to the modrow check. 0 (auto feed) and normal feeds are unchanged.

Checked with the band-fill loop from StartPage under ASan/UBSan. Before the fix, cupsRowFeed 0xFFFFFF38 gives a global-buffer-overflow READ and "index -73 out of bounds" on the write. After the fix it is rejected, and feeds 0, 1, 7, 13, 127 and 200 give the same band setup as before.

StartPage() takes DotRowFeed from the page header's cupsRowFeed and
only checks it for 0, then uses it to step the subrow that indexes
DotBands[128][7] while filling the initial softweave bands.  A
cupsRowFeed of 0x80000000 or more is negative as an int, so
(subrow + DotRowFeed) % modrow goes negative and the band setup reads
and writes DotBands[] before the start of the array; a feed close to
INT_MAX overflows the same sum.

Reject such a feed next to the existing modrow check.
@tillkamppeter
tillkamppeter merged commit 675c688 into OpenPrinting:master Nov 20, 2026
10 of 11 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.

2 participants