Skip to content

retain language per value in ippSetValueTag - #220

Closed
tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ipp-setvaluetag-language-ref
Closed

tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ipp-setvaluetag-language-ref

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

Since 4be235f, ipp_free_values releases the language of every nameWithLanguage/textWithLanguage value, but ippSetValueTag still converts a multi-valued name/keyword/text attribute by taking a single _cupsStrAlloc reference for values[0] and copying that pointer into the other values. Deleting the converted attribute then drops the pooled language string once per value, so with three values the "en" pool entry that attributes-natural-language also references is freed while that attribute still points at it. AddressSanitizer reports a heap-use-after-free in compare_sp_items via _cupsStrFree from ipp_free_values (ippDeleteAttribute), with the freed block being the attributes-natural-language string allocated by ippAddString. I found it while checking the remaining places that share values[0].string.language after the #215 change. Taking a reference per value matches what ippAddStrings, ippCopyAttribute and ippSetString now do. The same block always set the tag to nameWithLanguage, so a text to textWithLanguage conversion came back as nameWithLanguage; it now uses the requested tag. The new testipp case converts 3-valued name and text attributes and deletes them: it hits the use-after-free under ASan on the current tree and passes with the fix.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need to add a unit test for this... Definitely an edge-case (not aware of any code that actually calls ippSetValueTag to convert from name/textWithoutLanguage to name/textWithLanguage) and there is currently no way to set the language after attribute creation.

michaelrsweet added a commit that referenced this pull request Nov 19, 2026
@michaelrsweet michaelrsweet self-assigned this Nov 19, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Nov 19, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Nov 19, 2026
@michaelrsweet

Copy link
Copy Markdown
Member

[master 94905f0] Update ippSetValueTag handling of language tags to be consistent with other fixes (Issue #220)

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants