OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
37 stars 18 forks source link

IPP_TAG_EXTENSION is not implemented correctly #80

Closed michaelrsweet closed 8 months ago

michaelrsweet commented 8 months ago

Originally reported by Alexander Pevzner on the printing-architecture list...

IPP_TAG_EXTENSION is used to indicate value tags greater than 127. While these have never seen usage in the wild (whether standards-based or for a vendor implementartion), the current CUPS code will incorrectly place the vendor tag outside the value, causing all sorts of problems. Instead, tag 0x7f should just be a binary value whose first four bytes make a big-endian integer holding the extension tag value.

michaelrsweet commented 8 months ago

[master bf38abb60] Fix encoding of extension values (Issue #80)

Changes are basically to just pack the whole extension value as a binary string, and to make the ippGet/SetOctetString functions support reading/setting the value. You can't directly add an extension value, you need to first create an octetString and then set the value tag, e.g.:

ipp_attribute_t *attr = ippAddOctetString(ipp, IPP_TAG_..., "name", data, datalen);
ippSetValueTag(ipp, &attr, IPP_TAG_EXTENSION);

Copying the value also works.

Note: There are no known implementations that use extension values, so this is more to ensure that CUPS can handle them properly.