OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
958 stars 174 forks source link

IPP_TAG_EXTENSION is not implemented correctly #913

Closed michaelrsweet closed 3 months ago

michaelrsweet commented 3 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 3 months ago

[master 5de015846] Fix encoding of extension values (Issue #913)

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.