evdev: Fix 'Syscall param ioctl(TIOCLINUX) points to uninitialised byte'
authorBrandon Schaefer <brandon.schaefer@canonical.com>
Fri, 28 Jul 2017 12:00:10 -0700
changeset 111633fe70754ed33
parent 11162 a781e1dd03da
child 11164 3862687cef22
evdev: Fix 'Syscall param ioctl(TIOCLINUX) points to uninitialised byte'

https://pastebin.com/raw/tQjG0kG0
src/core/linux/SDL_evdev_kbd.c
     1.1 --- a/src/core/linux/SDL_evdev_kbd.c	Thu Jul 27 22:55:18 2017 -0700
     1.2 +++ b/src/core/linux/SDL_evdev_kbd.c	Fri Jul 28 12:00:10 2017 -0700
     1.3 @@ -196,7 +196,8 @@
     1.4  {
     1.5      SDL_EVDEV_keyboard_state *kbd;
     1.6      int i;
     1.7 -    char shift_state, flag_state;
     1.8 +    char flag_state;
     1.9 +    char shift_state[2] = {TIOCL_GETSHIFTSTATE, 0};
    1.10  
    1.11      kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd));
    1.12      if (!kbd) {
    1.13 @@ -208,9 +209,8 @@
    1.14      /* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
    1.15      kbd->console_fd = open("/dev/tty", O_RDONLY);
    1.16  
    1.17 -    shift_state = TIOCL_GETSHIFTSTATE;
    1.18 -    if (ioctl(kbd->console_fd, TIOCLINUX, &shift_state) == 0) {
    1.19 -        kbd->shift_state = shift_state;
    1.20 +    if (ioctl(kbd->console_fd, TIOCLINUX, shift_state) == 0) {
    1.21 +        kbd->shift_state = *shift_state;
    1.22      }
    1.23  
    1.24      if (ioctl(kbd->console_fd, KDGKBLED, &flag_state) == 0) {