RFC 1179 lpr issue blocks queue (and patch for 1.1.23)

Damien Wiles dwiles at chi.ac.uk
Mon Dec 12 03:40:30 PST 2005


Cups breaks RFC1179 Section 7.2 when passing IPP jobs to lpr by allowing control
data that are too long. This is a problem because:

    Netware lpd blocks jobs breaking RFC1179 control data lengths.

    We started to print to Netware lpd. Previous systems hadn't cared.

    Manual intervention is required for jobs stopped by this incompatibility.

    Apples native printing system is cups.

    Many websites use HTML spec breaking (>64 chars) titles now.

    Some apps use the first line of a document as the print title.

The RFC1179 issue surfaced when we did a tcpdump of a print job. Cups logs
reported 'the remote host has rejected the control file' and not seen it as a
true reject for some reason, thus blocking the queue. Netware lpr actually said
'title length breaks RFC1179 spec'.

Workaround...

either: don't use netware lpr. it's fussier than anything about RFC1179
or:
#Patch for backends/lpd.c
705c705,709
<     localhost[31] = '\0'; /* RFC 1179, Section 7.2 - host name < 32 chars */
---
>     snprintf(control, sizeof(control),
>              "H%.31s\n" /* RFC 1179, Sect. 7.2 - host name <= 31 char */
>  	     "P%.31s\n"	/* RFC 1179, Sect. 7.2 - user name <= 31 char */
>  	     "J%.99s\n", /* RFC 1179, Sect. 7.2 - job name <= 99 char */
>  	     localhost, user, title);
707,708d710
<     snprintf(control, sizeof(control), "H%s\nP%s\nJ%s\n", localhost, user,
<              title);
713c715,717
<       snprintf(cptr, sizeof(control) - (cptr - control), "C%s\nL%s\n",
---
>        snprintf(cptr, sizeof(control) - (cptr - control),
>                "C%.31s\n" /* RFC 1179, Sect. 7.2 - class name <= 31 char */
>  	       "L%s\n",
727c731
<              "UdfA%03d%.15s\nN%s\n",
---
>              "UdfA%03d%.15s\nN%.131s\n", /*
>               RFC 1179, Sect. 7.2 - source file name <= 131 char */
#end of patch

This is for backends/lpd.c as found in cups-1.1.23-r1 (gentoo)
Idea adapted (and fixed) from r4865 weekly build of cups. The snprintfs looked messed up in r4865, P.31%s, should read P%.31s unless I'm mistaken.

Anyone know how far back/forward this patch will work?

Hope I got it right, at least via our gentoo cups server the apples can print with ridiculous filenames/titles now :)







More information about the cups mailing list