Skip to content

pwgtopdf: limit bit conversion to raster row bytes - #211

Open
carrerasdarren-cell wants to merge 4 commits into
OpenPrinting:masterfrom
carrerasdarren-cell:fix/pwgtopdf-bit-row
Open

pwgtopdf: limit bit conversion to raster row bytes#211
carrerasdarren-cell wants to merge 4 commits into
OpenPrinting:masterfrom
carrerasdarren-cell:fix/pwgtopdf-bit-row

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown
Contributor

Summary

  • pass the validated raster row byte count to bit-conversion callbacks
  • add an end-to-end AddressSanitizer regression for a 128-pixel, 1-bit black raster row

Root cause

convert_raster() allocates PixelBuffer using cupsBytesPerLine, but passed the pixel width to callbacks that iterate byte-by-byte. For the reproducer, the row is 128 pixels but only 16 bytes, so invert_bits() accesses beyond the allocation.

The callback contract now names the value as bytes and receives bpl, matching the allocated buffer.

Testing

  • test-pwgtopdf-bit-row.sh fails with the original call under ASan and passes with this fix
  • test-pclm-overflow.sh passes
  • test-pdftoraster-copy-height passes when run with the locally configured PDFio include/library paths
  • the wider make check run passes the new test and neighboring filter tests; four legacy font tests are unavailable in this local configuration because the configured font path is no

Fixes #190.

Assisted-by: OpenAI Codex

The bit conversion callbacks operate on bytes, but convert_raster passed the pixel width. For 1-bit raster rows this made invert_bits overrun the row buffer.

Pass the validated byte count and add an end-to-end AddressSanitizer regression for a 128-pixel, 16-byte black raster row.

Assisted-by: OpenAI Codex
Link the sanitizer harness through pkg-config so lcms2, PDFio, and the selected CUPS generation are available across the CI matrix.

Assisted-by: OpenAI Codex
Run a trivial sanitized executable before the regression test so QEMU jobs that can link but cannot initialize AddressSanitizer skip cleanly.

Assisted-by: OpenAI Codex
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.

pwgtopdf: 1-bit black raster causes a heap-buffer-overflow

1 participant