[Xfce4-commits] r26491 - xfce-mcs-plugins/branches/xfce_4_4/plugins/mouse_plugin

Brian Tarricone kelnos at xfce.org
Tue Dec 18 01:25:52 CET 2007


Author: kelnos
Date: 2007-12-18 00:25:52 +0000 (Tue, 18 Dec 2007)
New Revision: 26491

Modified:
   xfce-mcs-plugins/branches/xfce_4_4/plugins/mouse_plugin/mouse_plugin.c
Log:
fix bad use of alloca(), fix buffer overflow with > 16 button mice (bug 3753)


Modified: xfce-mcs-plugins/branches/xfce_4_4/plugins/mouse_plugin/mouse_plugin.c
===================================================================
--- xfce-mcs-plugins/branches/xfce_4_4/plugins/mouse_plugin/mouse_plugin.c	2007-12-17 18:23:16 UTC (rev 26490)
+++ xfce-mcs-plugins/branches/xfce_4_4/plugins/mouse_plugin/mouse_plugin.c	2007-12-18 00:25:52 UTC (rev 26491)
@@ -174,7 +174,7 @@
     unsigned char *buttons;
     gint n_buttons, n_devices, i;
     gint idx_1 = 0, idx_3 = 1;
-    gsize buttons_capacity = 16;
+    gsize buttons_capacity = DEFAULT_PTR_MAP_SIZE;
 
     device_info = XListInputDevices (GDK_DISPLAY (), &n_devices);
 
@@ -204,11 +204,12 @@
             continue;
         }
 
-        n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, DEFAULT_PTR_MAP_SIZE);
-        if (n_buttons > DEFAULT_PTR_MAP_SIZE)
+        n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, buttons_capacity);
+        if (n_buttons > buttons_capacity)
         {
-            buttons = g_alloca (n_buttons);
-            n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, n_buttons);
+            buttons = g_realloc (buttons, n_buttons);
+            buttons_capacity = n_buttons;
+            n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, buttons_capacity);
         }
 
         for (i = 0; i < n_buttons; i++)



More information about the Xfce4-commits mailing list