Skip to content

src/keycode: fix buffer overflow#575

Merged
oktapodia merged 1 commit intooctalmage:masterfrom
bk138:master
Apr 22, 2020
Merged

src/keycode: fix buffer overflow#575
oktapodia merged 1 commit intooctalmage:masterfrom
bk138:master

Conversation

@bk138
Copy link
Copy Markdown
Contributor

@bk138 bk138 commented Apr 21, 2020

At

(const void **)&code)) {
,
sizeof(void*) bytes (probably 8) are written to a memory
segment of 2 bytes (a 16-bit CGKeycode variable), resulting in all
kinds of weird behaviour, like unrelated variables getting NULLed.

Making code a a type that can hold sizeof(void*) bytes fixes this.

Closes #570

At
https://github.com/octalmage/robotjs/blob/b26c7ee0e3dd05420370350e540c48ae9d38f06c/src/keycode.c#L98,
`sizeof(void*)` bytes (probably 8) are written to a memory
segment of 2 bytes (a 16-bit CGKeycode variable), resulting in all
kinds of weird behaviour, like unrelated variables getting NULLed.

Making `code` a a type that can hold `sizeof(void*)` bytes fixes this.

Closes #570
@oktapodia
Copy link
Copy Markdown
Collaborator

Thank you for your PR

@oktapodia oktapodia merged commit 56c2e03 into octalmage:master Apr 22, 2020
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.

keyToggle: EXC_BAD_ACCESS at createStringForKey + 68

2 participants