Skip to content

backend/ipp: Fix report_attr() to handle localized and octetString IPP tags#1510

Open
g0r3 wants to merge 2 commits intoOpenPrinting:masterfrom
g0r3:fix-report-attr-localized-tags
Open

backend/ipp: Fix report_attr() to handle localized and octetString IPP tags#1510
g0r3 wants to merge 2 commits intoOpenPrinting:masterfrom
g0r3:fix-report-attr-localized-tags

Conversation

@g0r3
Copy link

@g0r3 g0r3 commented Mar 13, 2026

I've started using the the IPP Everywhere driver with my Brother MFC-L3750CDW, as I had problems using the proprietary driver on Nixos. And while IPP Everywhere resolves that problem and works great for printing, I found that it doesn't provide the toner status.

lpstat showed no toner levels even though ipptool showed the data was there. I have programming experience, but I am not a versed C guy, so I used the help of an LLM to trace the code path and identify the problem. Not sure if this is accepted.

The error description and fix according to the LLM:

What's happening

ippFindAttribute() correctly matches localized types to their base
types (e.g., NAMELANGNAME) in cups/ipp.c. But report_attr()
switches on attr->value_tag (the actual tag, e.g., NAMELANG), and
its switch only covers INTEGER, TEXT, NAME, and KEYWORD. The
unhandled tag falls through to default: return;, silently dropping
the data.

Fix

Add IPP_TAG_TEXTLANG, IPP_TAG_NAMELANG, and IPP_TAG_STRING as
fall-through cases. They use the same string.text union member, so
no additional logic is needed.

I've tested the patch locally with my Brother MCF-L3750CDW with IPP Everywhere.
After applying the patch the toner levels are correctly reported in lpstat and (in my case) the KDE printer settings.

@michaelrsweet michaelrsweet self-assigned this Mar 13, 2026
@michaelrsweet
Copy link
Member

OK, so first you can't use string.text for IPP_TAG_STRING because that syntax is a binary string that can contain nul characters.

Will review this in more detail when I have a chance...

@g0r3
Copy link
Author

g0r3 commented Mar 14, 2026

OK, thanks for the heads-up. I've removed it from the fall-through cases.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants