Skip to content

Fix ATTR-IF-DEFINED/ATTR-IF-NOT-DEFINED handling in ippFileRead - #185

Open
anabobillo3 wants to merge 1 commit into
OpenPrinting:masterfrom
anabobillo3:ippfile-attrif
Open

anabobillo3 wants to merge 1 commit into
OpenPrinting:masterfrom
anabobillo3:ippfile-attrif

Conversation

@anabobillo3

Copy link
Copy Markdown
Contributor

ippFileRead only tested the ATTR-IF-DEFINED/ATTR-IF-NOT-DEFINED variable when the attribute callback rejected the attribute name:

  • Without a callback (ipptool), the attribute was always added, whether or not the variable was defined.
  • With a callback (ippeveprinter), a name the callback rejected was still added when the condition held, and when the condition failed the value was read into the ignored message, which this branch never allocated, so the line failed with "Unsupported value".

The directive also left attr pointing at the previous attribute. An out-of-band ATTR-IF-* value adds no attribute, so a following , line appended its value to the previous attribute, possibly in a different ipp_t (ignored vs. the file's attributes). ATTR and DEFINE already reset attr.

This change tests the variable first and then the callback, allocates ignored when it is first needed, and resets attr like the other directives.

testipp gains test_file_attr_if, run without and with an attribute callback. It checks which conditional attributes end up in the message, and that a , after an out-of-band ATTR-IF-NOT-DEFINED value is reported as an error instead of adding a value to the previous attribute. On current master both checks fail in both modes; with this change they pass, including under AddressSanitizer. The other unit tests pass on Linux (testdnssd not run, no Avahi daemon in the build container).

Assisted-by: Claude Code:claude-opus-5-5

The conditional attribute directives only tested the variable when the
attribute callback rejected the name, so without a callback (ipptool) the
attribute was always added and with one (ippeveprinter) a rejected name
was added when the condition held.  Test the variable first, then the
callback, and read skipped attributes into the ignored message, which is
now allocated when first used.

Also reset the current attribute like the ATTR and DEFINE directives do,
so a "," after an out-of-band ATTR-IF-* value no longer adds a value to
the previous attribute, possibly in a different ipp_t.

Add unit tests for both cases to testipp.
@michaelrsweet

Copy link
Copy Markdown
Member

As with the CUPS bug of the same name, I need more time to look at this...

This branch has not been deployed

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

Labels

investigating Investigating the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants