Skip to content

pwgtopdf: reject a non-positive pclm-strip-height-preferred - #289

Open
ManasBagul23 wants to merge 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-pwgtopdf-strip-height-divzero
Open

ManasBagul23 wants to merge 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-pwgtopdf-strip-height-divzero

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

Problem

cfFilterPWGToPDF() copies the printer's pclm-strip-height-preferred IPP attribute straight into pdf.pclm_strip_height_preferred with no range check, then uses it as both a divisor and a modulo operand while computing the PCLm strip count and strip boundaries:

(height / info->pclm_strip_height_preferred) +
(height % info->pclm_strip_height_preferred ? 1 : 0)

A PPD or printer-attribute value of zero reaches that math unchanged and terminates the standalone pwgtopclm filter with SIGFPE before any raster row is processed -- a job-level denial of service triggerable through printer capability data.

Verified with a standalone build of the attribute-fetch-then-divide logic: a 0 attribute value crashes with a hardware divide-by-zero exception before the fix, and falls back to the default strip height (16) cleanly after it.

Fix

Only accept the attribute when it's a positive integer; fall back to the existing default strip height (16) otherwise, same as when the attribute is absent.

Fixes #177

cfFilterPWGToPDF() copies the printer's pclm-strip-height-preferred
IPP attribute straight into pdf.pclm_strip_height_preferred with no
range check, then uses it as both a divisor and a modulo operand
while computing the PCLm strip count and strip boundaries. A PPD or
printer-attribute value of zero reaches that math unchanged and
terminates the standalone pwgtopclm filter with SIGFPE before any
raster row is processed -- a job-level denial of service triggerable
through printer capability data.

Only accept the attribute when it's a positive integer; fall back to
the existing default strip height (16) otherwise, same as when the
attribute is absent.

Fixes OpenPrinting#177
Copilot AI balanced review requested due to automatic review settings October 16, 2026 19:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

pwgtopclm: zero preferred strip height causes division by zero

2 participants