evdev-touchpad: Iterate over the touchpad spec table correctly
authorRob Bradford <rob@linux.intel.com>
Tue, 9 Oct 2012 17:44:32 +0000 (18:44 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Sun, 10 Nov 2013 16:51:31 +0000 (17:51 +0100)
The original code would overrun since the calculation of the range did not
take into consideration the size of the entries in the table.

Cc:Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Rob Bradford <rob@linux.intel.com>
src/evdev-touchpad.c

index 4da37a5..8827b8b 100644 (file)
@@ -134,7 +134,7 @@ get_touchpad_model(struct evdev_device *device)
        if (ioctl(device->fd, EVIOCGID, &id) < 0)
                return TOUCHPAD_MODEL_UNKNOWN;
 
-       for (i = 0; i < sizeof touchpad_spec_table; i++)
+       for (i = 0; ARRAY_LENGTH(touchpad_spec_table); i++)
                if (touchpad_spec_table[i].vendor == id.vendor &&
                    (!touchpad_spec_table[i].product ||
                     touchpad_spec_table[i].product == id.product))