Skip to content

Commit

Permalink
src/keycode: fix buffer overflow
Browse files Browse the repository at this point in the history
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 octalmage#570
  • Loading branch information
bk138 committed Apr 21, 2020
1 parent 603de61 commit 274d03b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/keycode.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MMKeyCode keyCodeForChar(const char c)
/* OS X does not appear to have a built-in function for this, so instead we
* have to write our own. */
static CFMutableDictionaryRef charToCodeDict = NULL;
CGKeyCode code;
size_t code;
UniChar character = c;
CFStringRef charStr = NULL;

Expand Down

0 comments on commit 274d03b

Please sign in to comment.