[PATCH 4/8] evdev-touchpad: Iterate over the touchpad spec table correctly

Rob Bradford robert.bradford at intel.com
Tue Oct 9 10:44:32 PDT 2012


From: Rob Bradford <rob at linux.intel.com>

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 at gmail.com>
Signed-off-by: Rob Bradford <rob at linux.intel.com>
---
 src/evdev-touchpad.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/evdev-touchpad.c b/src/evdev-touchpad.c
index 4da37a5..8228f30 100644
--- a/src/evdev-touchpad.c
+++ b/src/evdev-touchpad.c
@@ -134,7 +134,9 @@ 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;
+	     i < sizeof touchpad_spec_table / sizeof touchpad_spec_table[0];
+	     i++)
 		if (touchpad_spec_table[i].vendor == id.vendor &&
 		    (!touchpad_spec_table[i].product ||
 		     touchpad_spec_table[i].product == id.product))
-- 
1.7.11.2



More information about the wayland-devel mailing list