OpenPrinting / OpenPrinting/libcupsfilters

cfFilterPWGToRaster divides by zero for zero input resolution

Open Beginner friendly
#165 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17
Forks
71
Avg merge
2d 17h
Merged PRs (30d)
13

Description

Summary

cfFilterPWGToRaster() accepts a PWG Raster page header with a zero HWResolution component, then performs modulo/division using it while calculating output scaling.

Reproduction

Build current upstream with ASan/UBSan. Start from a one-page PWG Raster stream (2SaR / PwgRaster sync), retain a parseable header and one byte of gray pixel data, then set the input page HWResolution to [0, 76800]. The tested page is 1 x 1, 8-bit gray; the PPD requests a normal 300-dpi output page.

ASAN_OPTIONS=detect_leaks=0 PPD=candidate.ppd CONTENT_TYPE=application/vnd.cups-pwg 
  pwgtoraster 1 fuzzer fuzzer 1 'PageSize=Small MediaType=Plain Duplex=None' document.pwg >/dev/null

Result

Reproduced through the real pwgtoraster CLI with an ASan/UBSan build from libcupsfilters HEAD d63939da08eaef622a2443b7c9638d22c4d9831d and libppd HEAD 522af8dd135f4dde66b1aac8b9d067808bbe122d on 2026-07-19. ASan/UBSan reports an FPE in cupsfilters/pwgtoraster.c:1620:

if (doc->outheader.HWResolution[i] % doc->inheader.HWResolution[i])

Cause and expected behavior

Reject zero input or output resolution before modulo or division. The malformed page header is accepted before out_page() uses the unchecked component.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at cupsfilters/pwgtoraster.c:1620 and trace how the PWG page header reaches out_page() before the modulo and division. Use the provided pwgtoraster command with the ASan/UBSan build and zero HWResolution input; done means zero input or output resolution is rejected before arithmetic and the reproduction no longer reports an FPE.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.