Skip to content

Fix heap overflow in Razer SetupZones when KLM overlay expands grid#87

Open
NilsSei wants to merge 1 commit intoCalcProgrammer1:masterfrom
NilsSei:fix/razer-setup-zones-heap-overflow
Open

Fix heap overflow in Razer SetupZones when KLM overlay expands grid#87
NilsSei wants to merge 1 commit intoCalcProgrammer1:masterfrom
NilsSei:fix/razer-setup-zones-heap-overflow

Conversation

@NilsSei
Copy link
Copy Markdown

@NilsSei NilsSei commented May 8, 2026

KLM overlay opcodes (INSERT_SHIFT_RIGHT etc.) can expand the key grid beyond the zone's declared height/width. GetKeyMap writes up to max(declared, actual)^2 entries but the map buffer was only allocated for declared^2, causing a heap overflow and crash on affected devices (e.g. Razer Blade 15 Late 2021 Advanced).

Reallocate the map buffer to the actual KLM dimensions before calling GetKeyMap. new_map height/width intentionally remain at the declared values so the HID packet structure is unchanged.

KLM overlay opcodes (INSERT_SHIFT_RIGHT etc.) can expand the key grid
beyond the zone's declared height/width. GetKeyMap writes up to
max(declared, actual)^2 entries but the map buffer was only allocated
for declared^2, causing a heap overflow and crash on affected devices
(e.g. Razer Blade 15 Late 2021 Advanced).

Reallocate the map buffer to the actual KLM dimensions before calling
GetKeyMap. new_map height/width intentionally remain at the declared
values so the HID packet structure is unchanged.
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