Skip to content

ghostscript: serialize raster integer parameters as signed - #225

Open
victortrac wants to merge 1 commit into
OpenPrinting:masterfrom
victortrac:fix/ghostscript-signed-raster-params
Open

ghostscript: serialize raster integer parameters as signed#225
victortrac wants to merge 1 commit into
OpenPrinting:masterfrom
victortrac:fix/ghostscript-signed-raster-params

Conversation

@victortrac

Copy link
Copy Markdown

Fixes #218.
Related to #222.

Problem

Commit b558b36 changed several Ghostscript CUPS raster parameters from
signed (%d) to unsigned (%u) formatting.

Some fields in cups_page_header_t are unsigned storage locations but
legitimately contain the two's-complement representation of signed values.
For example, label-printer PPDs use:

  <</cupsCompression -1>>setpagedevice

With libcupsfilters 2.2.1 this is emitted as:

  -dcupsCompression=4294967295

Ghostscript reads these device properties using its signed
param_read_int() interface, rejects the value, and terminates with:

  Error setting cupsCompression
  Unrecoverable error: rangecheck in .putdeviceprops

The same signedness problem affects cupsInteger[], as demonstrated by
issue #222.

Fix

Serialize CUPS raster integer fields using %d with an explicit (int)
conversion. This preserves signed values while avoiding the original
printf argument-type mismatch.

Reproduction

Environment:

  • Arch Linux x86_64
  • CUPS 2.4.19
  • cups-filters 2.0.1
  • libcupsfilters 2.2.1
  • libppd 2.1.1
  • Ghostscript 10.07.1
  • 4BARCODE 4B-2054K using the standard ZPL rastertolabel PPD

Using the PPD default Darkness=-1:

  • Unpatched 2.2.1:
    • emits -dcupsCompression=4294967295
    • exits with status 1
    • produces 0 raster bytes
  • Patched 2.2.1:
    • emits -dcupsCompression=-1
    • exits with status 0
    • produces 500,340 raster bytes

The test invokes the universal filter directly with the same PPD and
input PDF, changing only the loaded libcupsfilters library.

Testing

  • make check: 9 passed, 0 failed
  • Arch package built successfully
  • Direct unpatched/patched A/B rasterization test passed
  • Live printing through the patched package succeeded

patched-2.2.1.log
unpatched-2.2.1.log

Signed-off-by: Victor Trac <victor@cloudkite.io>
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.

cfFilterGhostscript fails with rangecheck when PPD sets cupsCompression=-1

1 participant