Skip to content

avoid use-after-free in ippDeleteAttribute during iteration - #237

Merged
michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ippdeleteattribute-dangling-find
Dec 2, 2026
Merged

michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ippdeleteattribute-dangling-find

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

Use-after-free when deleting the attribute returned during iteration

ippDeleteAttribute() unlinks and frees an attribute and fixes ipp->attrs and ipp->last, but leaves ipp->current, ipp->prev, and the find-stack entries in ipp->fstack[] still pointing at the freed attribute, even though ipp_set_value() keeps those same pointers valid when it reallocates an attribute. After ippGetFirstAttribute()/ippGetNextAttribute() iteration deletes the current attribute, ipp->find->attr dangles, and the next ippGetNextAttribute() reads the freed attribute's next pointer and returns a dangling pointer the caller then dereferences.

This resets ipp->current, ipp->prev, and any ipp->fstack[] entry that references the attribute being freed to its list predecessor (or NULL), so later iteration or value changes stay on live memory. testipp gains a regression that deletes the current attribute mid-iteration and then reads the next one; it reports a heap use-after-free under AddressSanitizer before the change and passes after.

@michaelrsweet michaelrsweet self-assigned this Dec 2, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Dec 2, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Dec 2, 2026

@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.

LGTM, thanks!

@michaelrsweet
michaelrsweet merged commit bc662a8 into OpenPrinting:master Dec 2, 2026
6 checks passed
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