Skip to content

libcups2: stop ppd_unquote() reading past a trailing backslash - #115

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/libcups2-unquote-trailing-backslash-overread
Nov 21, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/libcups2-unquote-trailing-backslash-overread

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

Summary

`ppd_unquote()` unescapes a `.po`/`.strings` value in place.

The bug

When a value ends in a literal backslash just before the closing quote (the caller already stripped that quote and NUL-terminated the string there), the function advances past the backslash with `s++` and immediately dereferences `*s` again without checking whether that landed on the terminating NUL. Since there is nothing past the NUL for a value that ends right there, this reads one byte past the end of the string's allocation.

Fix

Stop and leave the backslash as the end of output if nothing follows it, instead of reading past the string.

Test plan

  • Reproduced a real crash with a guard-page test: placed such a string so its NUL lands on the last byte of a mapped page, with the next page unmapped. The unpatched function reliably segfaults; the fixed version returns cleanly.

ppd_unquote() unescapes a .po/.strings value in place. When a value
ends in a literal backslash just before the closing quote (the caller
already stripped that quote and NUL-terminated the string there), the
function advances past the backslash with "s++" and immediately
dereferences *s again without checking whether that landed on the
terminating NUL. Since there is nothing past the NUL for a value that
ends right there, this reads one byte past the end of the string's
allocation; reproduced a crash by placing such a string so its NUL
lands on the last byte of a mapped page, with the next page
unreadable.

Stop and leave the backslash as the end of output if nothing follows
it, instead of reading past the string.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@tillkamppeter
tillkamppeter merged commit 93ed849 into OpenPrinting:master Nov 21, 2026
14 of 15 checks passed
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.

3 participants