Skip to content

core: fix compose result over-read in handleKeySym - #1086

Open
martintrojer wants to merge 1 commit into
hyprwm:mainfrom
martintrojer:hl-compose-overread
Open

martintrojer wants to merge 1 commit into
hyprwm:mainfrom
martintrojer:hl-compose-overread

Conversation

@martintrojer

@martintrojer martintrojer commented Oct 28, 2026 •

Copy link
Copy Markdown

xkb_compose_state_get_utf8 returns the full length even if the buffer is too small. With a 16 byte stack buffer, a compose result of 16+ bytes makes std::string{buf, len-1} read past it.

Needs a user ~/.XCompose; the longest stock entry here is 6 bytes. ASan build on headless sway: 17 bytes gives stack-buffer-overflow READ of size 17, 36 bytes reads 36. At exactly 16 a NUL ends up in the password.

Fix asks for the length first and sizes the string to it. 15/16/17/36 bytes and a 21 byte UTF-8 result all come out complete with no ASan report.

@martintrojer
martintrojer marked this pull request as ready for review October 28, 2026 10:33
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.

1 participant