apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.93k stars 464 forks source link

Invalid IPP response #1431

Closed michaelrsweet closed 18 years ago

michaelrsweet commented 18 years ago

Version: 1.1.23 CUPS.org User: elkner

If DefaultLanguage is not set in /etc/cups/cupsd.conf (i.e. commented out) CUPS sends an invalid IPP response, which causes e.g. Java (verified for all >= 1.4) to fail with java.lang.IndexOutOfBoundsException, since the decoder relies on the fact, that a value is always prefixed with 2 bytes (length of value).

E.g.: ... 0x08f0: 001b 6e61 7475 7261 6c2d 6c61 6e67 7561 ..natural-langua 0x0900: 6765 2d63 6f6e 6669 6775 7265 6400 a46c ge-configured..l 0x0910: 632d 6374 7970 653d 656e 2d75 733b 6c63 c-ctype=en-us;lc ... 0x09b0: 6e3d 6348 0024 6765 6e65 7261 7465 642d n=cH.$generated- 0x09c0: 6e61 7475 7261 6c2d 6c61 6e67 7561 6765 natural-language 0x09d0: 2d73 7570 706f 7274 6564 00a4 6c63 2d63 -supported..lc-c 0x09e0: 7479 7065 3d65 6e2d 7573 3b6c 632d 6e75 type=en-us;lc-nu ...

In case you need the complete conversation between CUPS and the Java client, please let me know.

michaelrsweet commented 18 years ago

CUPS.org User: mike

Yes, please attach both the request you are sending and the response you received.

Also, what Java software are you using to send the request?

michaelrsweet commented 18 years ago

CUPS.org User: mike

What Java software are you using to send the request?

The request and response both seem to use "utf-8" and "en" for the charset and language, respectively, and DefaultCharset and DefaultLanguage are not used for populating the IPP natural-language stuff unless the request does not provide them (which it apparently does...)

michaelrsweet commented 18 years ago

CUPS.org User: elkner

java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

Well, for tracking I use a selfwritten test, which does the same, as the Java application (since the sun.print.* sources are not available in the JDK itself). The error gets triggered in the Java application e.g. via javax.swing.JTable.print().

If you want the little test app, I use for tracking this problem, let me know (in this case I would need a non public email address, since it contains the original, proprietary code snipplet of sun.print.IPPPrintService.readIPPResponse).

But anyway, even if the languages are provided (which might be AFAIK not a bad thing), CUPS should not generate invalid responses (even if it doesn't understand, what's beeing sent).

michaelrsweet commented 18 years ago

CUPS.org User: mike

OK, I've decoded the hex data from the requests and responses - all four sets contain valid IPP messages, so you need to report this as a BUG to Sun. Here is the output from cups/testipp:

response2.out:

operation-attributes-tag:

attributes-charset (charset): "utf-8"
attributes-natural-language (naturalLanguage): "en"

printer-attributes-tag:

printer-uri-supported (uri): "ipp://elke:631/printers/ps"
uri-authentication-supported (keyword): "requesting-user-name"
uri-security-supported (keyword): "none"
printer-name (nameWithoutLanguage): "ps"
printer-location (textWithoutLanguage): "/tmp/username"
printer-info (textWithoutLanguage): "Virtual PS file printer"
printer-more-info (uri): "ipp://elke:631/printers/ps"
job-quota-period (integer): 0
job-k-limit (integer): 0
job-page-limit (integer): 0
job-sheets-default (1setOf nameWithoutLanguage): "none" "none"
device-uri (uri): "cups-ps:/"
color-supported (boolean): false
pages-per-minute (integer): 35
printer-make-and-model (textWithoutLanguage): "HP LaserJet 4200 PS v3010.108"
media-supported (1setOf keyword): "Upper" "ManualFeedTray" "Middle" "EnvFeed" "Tray3_500" "Tray3_1500" "Tray4_500" "Tray4_1500" "Plain" "Preprinted" "Letterhead" "Transparency" "Prepunched" "Labels" "Bond" "Recycled" "Color" "CardStock164" "Rough" "Envelope" "Auto" "Letter" "Executive" "Legal" "A4" "A5" "w499h709" "B5" "DoublePostcard" "w612h935" "w558h774" "Env10" "EnvMonarch" "EnvDL" "EnvC5" "EnvISOB5" "Custom"
media-default (keyword): "A4"
output-bin-supported (1setOf keyword): "Auto" "Upper" "Stacker"
sides-supported (1setOf keyword): "one" "two-long-edge" "two-short-edge"
sides-default (keyword): "one"
finishings-supported (1setOf enum): 3 4
finishings-default (enum): 3
printer-type (enum): 36980
pdl-override-supported (keyword): "not-attempted"
ipp-versions-supported (1setOf keyword): "1.0" "1.1"
operations-supported (1setOf enum): 2 4 5 6 8 9 10 11 12 13 16 17 18 20 34 35 16385 16386 16387 16388 16389 16390 16391 16392 16393 16395 16396 14
multiple-document-jobs-supported (boolean): true
multiple-operation-time-out (integer): 60
multiple-document-handling-supported (1setOf keyword): "separate-documents-uncollated-copies" "separate-documents-collated-copies"
charset-configured (charset): "utf-8"
charset-supported (1setOf charset): "us-ascii" "iso-8859-1" "iso-8859-2" "iso-8859-3" "iso-8859-4" "iso-8859-5" "iso-8859-6" "iso-8859-7" "iso-8859-8" "iso-8859-9" "iso-8859-10" "iso-8859-13" "iso-8859-14" "iso-8859-15" "utf-8" "windows-874" "windows-1250" "windows-1251" "windows-1252" "windows-1253" "windows-1254" "windows-1255" "windows-1256" "windows-1257" "windows-1258" "koi8-r" "koi8-u"
natural-language-configured (naturalLanguage): "lc-ctype=en-us;lc-numeric=c;lc-time=c;lc-collate=c;lc-monetary=c;lc-messages=c;lc-paper=c;lc-name=c;lc-address=c;lc-telephone=c;lc-measurement=c;lc-identification=c"
generated-natural-language-supported (naturalLanguage): "lc-ctype=en-us;lc-numeric=c;lc-time=c;lc-collate=c;lc-monetary=c;lc-messages=c;lc-paper=c;lc-name=c;lc-address=c;lc-telephone=c;lc-measurement=c;lc-identification=c"
document-format-default (mimeMediaType): "application/octet-stream"
document-format-supported (1setOf mimeMediaType): "application/msword" "application/pdf" "application/postscript" "application/vnd.cups-command" "application/vnd.cups-form" "application/vnd.cups-postscript" "application/vnd.cups-raster" "application/vnd.cups-raw" "application/vnd.hp-hpgl" "application/x-cshell" "application/x-perl" "application/x-shell" "image/gif" "image/jpeg" "image/png" "image/tiff" "image/x-alias" "image/x-bitmap" "image/x-photocd" "image/x-portable-anymap" "image/x-portable-bitmap" "image/x-portable-graymap" "image/x-portable-pixmap" "image/x-sgi-rgb" "image/x-sun-raster" "image/x-xbitmap" "image/x-xpixmap" "image/x-xwindowdump" "text/html" "text/plain" "application/octet-stream"
compression-supported (1setOf keyword): "none" "gzip"
job-priority-supported (integer): 100
job-priority-default (integer): 50
copies-supported (rangeOfInteger): 1-100
copies-default (integer): 1
page-ranges-supported (boolean): true
number-up-supported (1setOf integer): 1 2 4 6 9 16
number-up-default (integer): 1
orientation-requested-supported (1setOf enum): 3 4 5 6
orientation-requested-default (enum): 3
job-hold-until-supported (1setOf keyword): "no-hold" "indefinite" "day-time" "evening" "night" "second-shift" "third-shift" "weekend"
job-hold-until-default (keyword): "no-hold"
job-sheets-supported (1setOf nameWithoutLanguage): "none" "classified" "confidential" "secret" "standard" "topsecret" "unclassified"