Commit 739d3ec189e52c25233418336fe07918f9e6b91d

Mathieu Eyraud 2023-08-10T15:05:29

Fix out of bound read of 'has_hat' array (cherry picked from commit 94b3f78c440bfd52182848adf39db71325861e9c) (cherry picked from commit f348370e1b3416f70e3fd1e5668a385b661b4a48)

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 06f227b..479beb1 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -1041,7 +1041,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd)
         }
         for (i = 0; i < ABS_MAX; ++i) {
             /* Skip digital hats */
-            if (joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) {
+            if (i >= ABS_HAT0X && i <= ABS_HAT3Y && joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) {
                 continue;
             }
             if (test_bit(i, absbit)) {