Skip to content

rastertoescpx: validate PPD row geometry before sizing - #720

Open
carrerasdarren-cell wants to merge 1 commit into
OpenPrinting:masterfrom
carrerasdarren-cell:agent/validate-escp-black-row-geometry
Open

rastertoescpx: validate PPD row geometry before sizing#720
carrerasdarren-cell wants to merge 1 commit into
OpenPrinting:masterfrom
carrerasdarren-cell:agent/validate-escp-black-row-geometry

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Summary

  • apply cupsESCPBlack row overrides before deriving softweave schedules and buffer sizes
  • reject invalid, overflowing, or out-of-range row geometry
  • use checked size_t arithmetic and verify the affected allocations

Problem

StartPage() calculated DotRowMax and the compression-buffer capacity from the raster header, then allowed cupsESCPBlack to replace DotRowCount and DotRowStep. The PPD from #715 changes the row count from 2 to 30, so a 29-row band reaches CompressData() while CompBuffer still has capacity for only two rows.

The override is now parsed and validated before any dependent state is calculated. The validation also bounds the fixed 128-entry weave schedule and prevents integer overflow in the compression allocation.

Fixes #715.

Testing

  • exact public PPD/raster on untouched source: ASAN reports the 104-byte heap-buffer-overflow write
  • exact public PPD/raster after this patch: exits 0 under ASAN/UBSAN with DotRowMax = 30
  • valid 2 1 control: byte-identical output before and after the patch
  • invalid 0 1, 30 0, 2147483647 2, 30 129, and malformed controls: rejected cleanly
  • full ASAN/UBSAN build
  • make -j2 check

Apply cupsESCPBlack overrides before calculating softweave schedules and buffer capacities. Reject invalid or overflowing row geometry, use checked size_t arithmetic for the compression allocation, and handle the affected allocation failures. This prevents the undersized compression buffer reported in issue OpenPrinting#715.
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.

rastertoescpx: a PPD row-count override causes a heap-buffer-overflow

1 participant