OpenPrinting / OpenPrinting/libcupsfilters
cfFilterPWGToRaster divides by zero for zero input resolution
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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