Skip to content

foomatic-rip crashes on titles with some special characters on Ricoh PS PPDs #52

Open

Description

@akorobkin

Describe the bug
Job title TPS7A52 2-A, High-Accuracy (0.5%), Low-Noise (4.4 µVRMS), LDO Voltage Regulator datasheet (Rev. A) consistently crashes foomatic-rip filter.

To Reproduce
Steps to reproduce the behavior:

  1. Open attached PDF, or generate your own with this title. TPS7A52 2-A, High-Accuracy (0.5%), Low-Noise (4.4 µVRMS), LDO Voltage Regulator datasheet (Rev. A).pdf

  2. Print it to a foomatic-rip enabled PPD. In my case Ricoh MP C3004

  3. See this error in the logs.

D [02/Jul/2025:18:50:21 +0000] [Job 5009144] New page: %%Page: 1 1
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] \"Setup\" section is missing, inserting it.
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Found: %%BeginPageSetup
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Inserting option code into \"PageSetup\" section.
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] New page found but previous not printed, print it now.
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Found: %%Page: 2 2
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] --> Output goes directly to the renderer now.
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Starting renderer with command: \"printf \"%%!PS-Adobe-3.0
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] %%%%Title: (TPS7A52 2-A, High-Accuracy 0.5%, Low-Noi)
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] %%
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] %%\\n/usrid(shengwen)def\\n/lppswd()def\\n/dspswd()def\\n/usrcode()def\\nmark\\n/usrcode where{pop}{/usrcode()def}ifelse\\n/usrid where{pop}{/usrid()def}ifelse\\n(shengwen) usrcode (20`date +%y%m%d%R | sed \'s/://\'`) {setuserinfo} stopped\\ncleartomark\\nmark {\\n<<\\n   /JobType 0\\n   /JobInfo <<\\n      /UserID usrid\\n      /Time (20`date +%y%m%d%R | sed \'s/://\'`)\\n      /HostLoginName (shengwen)\\n      /HostName (mp-amer-00.c.papercut-in-the-cloud-prod.internal)\\n   >>\\n>> /RDeviceProcSet /ProcSet findresource /SetJobType get exec\\n}stopped cleartomark\\nmark{\\n<</OutputType null>>setpagedevice\\n} stopped cleartomark\\nmark{\\nuserdict /RPS_BPdict 2 dict put\\nuserdict /RPS_BPdict get begin /RPS_BP_MEDIAPOSITION null def end\\n} stopped cleartomark\\nmark{\\nuserdict /RPS_BPdict get begin\\n/RPS_BP_MEDIATYPE (Auto) def end\\n} stopped cleartomark\\nmark{\\n<<\\n/BannerPageMode false\\n/MediaPosition null\\n/MediaType null\\n>>\\n/RDeviceProcSet\\n/ProcSet findresource\\n/SetBannerPage get exec\\n} stopped cleartomark\\n\"%%%%; cat;\"
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Starting process \"kid3\" (generation 1)
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Starting process \"kid4\" (generation 2)
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Starting process \"renderer\" (generation 2)
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] JCL: \033%-12345X@PJL
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] <job data> 
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] /bin/sh: line 4: printf: `,\': invalid format character
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] renderer exited with status 1
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Possible error on renderer command line or PostScript error. Check options.Process is dying with \"Encountered error Broken pipe during fwrite\", exit stat 1
D [02/Jul/2025:18:50:21 +0000] [Job 5009144] Cleaning up...

Expected behavior
It prints

System Information:

  • OS: Debian Testing 13
  • CUPS 2.4.12
  • cups-filters: 1.28.17-5

Activity

  1. gnoack commented on Sep 3, 2025

    @gnoack

    One thing up front, I do unfortunately lack the time and expertise to fix and verify PPD files, but I think I spotted the bug when I looked at the PPD file:

    The PPD file has an entry for *FoomaticRIPCommandLine:

    *FoomaticRIPCommandLine: "printf &quot;%%!PS-Adobe-3.0
    %%%%Title: (&title;)
    %%
    %%\n%A%B%C%D&quot;%%%%; cat;"
    *End
    

    CUPS replaces &title; with a sanitized document title before running this. But the title is only sanitized to be safe to use within a normal shell command. In this case, the title is placed not only within a command line argument, but more specifically that argument is a printf format string, which is interpreted by the printf(3) tool. Your title contains a % which is misinterpreted by printf as a (faulty) format string and results in the error "invalid format character" which you can see in your logs.

    Possible fixes include (a) using echo instead of printf, or (b) using a fixed format string with printf and passing the title as argument (e.g. printf "%s" "My title % with percent signs").

    P.S. I am confused what the %A%B%C%D is good for. This is not a valid format string either, from what I can tell.

  2. ValdikSS commented on Oct 19, 2025

    @ValdikSS
    Member

    Yeah, I'd say it's a PPD bug, it should be printf %s ... as @gnoack noticed.

  3. ValdikSS commented on Oct 19, 2025

    @ValdikSS
    Member

    @akorobkin could you please replace *FoomaticRIPCommandLine: "printf &quot;%%!PS-Adobe-3.0 with *FoomaticRIPCommandLine: "printf %s &quot;%%!PS-Adobe-3.0 in the PPD file, and confirm that it still works fine and as expected?

    It seems all the Ricoh and Ricoh-brand (Savin, Gestetner, Lanier, Infotec) PS PPD files have this issue.

    Edit: oh, it's not that simple.

  4. changed the title [-]foomatic-rip crashes on titles with some special characters[/-] [+]foomatic-rip crashes on titles with some special characters on Ricoh PS PPDs[/+] on Oct 19, 2025
  5. akorobkin commented on Oct 22, 2025

    @akorobkin
    Author

    Thank you for the hint. I patched foomatic-rip to omit % as a workaround, and now it works for me in my environment.

    --- a/filter/foomatic-rip/util.c
    +++ b/filter/foomatic-rip/util.c
    @@ -32,7 +32,7 @@
     #include <errno.h>
     
     
    -const char* shellescapes = "|;<>&!$\'\"`#*?()[]{}";
    +const char* shellescapes = "|;<>&!$\'\"`#*?()[]{}%";
     
     const char * temp_dir()
     {
    
  6. akorobkin commented on Oct 22, 2025

    @akorobkin
    Author

    Scratch that, I'd better remove %%%%Title: (&title;) from all my local PPDs. Thanks again for the advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions