octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.37k stars 961 forks source link

src/keycode: fix buffer overflow #575

Closed bk138 closed 4 years ago

bk138 commented 4 years ago

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 commented 4 years ago

Thank you for your PR