OpenPrinting / OpenPrinting/libcupsfilters

cfFilterPWGToPDF continues after page preparation fails

Open Beginner friendly
#166 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

A PWG Raster page with an unsupported color space makes pwgtopdf log Color space not supported and then crash through a null callback.

Reproduction

Build current upstream with ASan/UBSan. Start from a parseable one-page PWG Raster stream (2SaR / PwgRaster sync), retain a complete page header and minimal payload, then set cupsColorSpace to a value not supported by prepare_pdf_page().

ASAN_OPTIONS=detect_leaks=0 PPD=candidate.ppd CONTENT_TYPE=application/vnd.cups-pwg 
  pwgtopdf 1 fuzzer fuzzer 1 'Resolution=300dpi PageSize=Letter' document.pwg >/dev/null

Result

Reproduced through the real pwgtopdf CLI with an ASan/UBSan build from libcupsfilters HEAD d63939da08eaef622a2443b7c9638d22c4d9831d and libppd HEAD 522af8dd135f4dde66b1aac8b9d067808bbe122d on 2026-07-19. The filter logs cfFilterPWGToPDF: Color space not supported, then ASan reports a SEGV in convert_raster() at cupsfilters/pwgtopdf.c:1637, calling doc->bit_function.

Cause and expected behavior

prepare_pdf_page() returns an error without initializing conversion callbacks. add_pdf_page() ignores that result at cupsfilters/pwgtopdf.c:1491, and convert_raster() later calls doc->bit_function. Propagate the preparation failure and abort the job cleanly.

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 in cupsfilters/pwgtopdf.c at add_pdf_page() around line 1491, then follow prepare_pdf_page() and convert_raster() around line 1637. Re-run the supplied ASan/UBSan pwgtopdf command with an unsupported cupsColorSpace; done means the preparation error is propagated and the job aborts cleanly without calling the null conversion callback.

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
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.