xserver: Branch 'master' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Thu May 21 19:32:38 PDT 2009


 dix/inpututils.c               |   12 ++++--------
 hw/xfree86/common/xf86Config.c |   25 ++++++++++++++++---------
 xkb/xkb.c                      |    8 +++++---
 3 files changed, 25 insertions(+), 20 deletions(-)

New commits:
commit 525aa17f804d37d1cfcbbf6b8e6cddb45e999b20
Author: Tomas Janousek <tomi at nomi.cz>
Date:   Wed May 20 15:03:01 2009 +0200

    Bug #6428, #16458, #21464: Fix crash due to uninitialized VModMap fields.
    
    In ProcXkbGetKbdByName, mrep.firstVModMapKey, .nVModMapKeys and
    .totalVModMapKeys were not initialized, contained random values and caused
    accesses to unallocated and later modified memory, causing
    XkbSizeVirtualModMap and XkbWriteVirtualModMap to see different number of
    nonzero values, resulting in writes past the end of an array in XkbSendMap.
    
    This patch initializes those values sensibly and reverts commits 5c0a2088 and
    6dd4fc46, which have been plain non-sense.
    
    Signed-off-by: Tomas Janousek <tomi at nomi.cz>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 445c55f..ec46238 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -1308,7 +1308,7 @@ XkbSizeVirtualModMap(XkbDescPtr xkb,xkbGetMapReply *rep)
 	rep->totalVModMapKeys= 0;
 	return 0;
     }
-    for (nRtrn=i=0;i<rep->nVModMapKeys-1;i++) {
+    for (nRtrn=i=0;i<rep->nVModMapKeys;i++) {
 	if (xkb->server->vmodmap[i+rep->firstVModMapKey]!=0)
 	    nRtrn++;
     }
@@ -1327,7 +1327,7 @@ unsigned short *	pMap;
 
     wire= (xkbVModMapWireDesc *)buf;
     pMap= &xkb->server->vmodmap[rep->firstVModMapKey];
-    for (i=0;i<rep->nVModMapKeys-1;i++,pMap++) {
+    for (i=0;i<rep->nVModMapKeys;i++,pMap++) {
 	if (*pMap!=0) {
 	    wire->key= i+rep->firstVModMapKey;
 	    wire->vmods= *pMap;
@@ -5670,7 +5670,7 @@ ProcXkbGetKbdByName(ClientPtr client)
 	    mrep.present = 0;
 	    mrep.totalSyms = mrep.totalActs =
 		mrep.totalKeyBehaviors= mrep.totalKeyExplicit= 
-		mrep.totalModMapKeys= 0;
+		mrep.totalModMapKeys= mrep.totalVModMapKeys= 0;
 	    if (rep.reported&(XkbGBN_TypesMask|XkbGBN_ClientSymbolsMask)) {
 		mrep.present|= XkbKeyTypesMask;
 		mrep.firstType = 0;
@@ -5696,6 +5696,8 @@ ProcXkbGetKbdByName(ClientPtr client)
 			mrep.firstKeyExplicit = new->min_key_code;
 		mrep.nKeyActs = mrep.nKeyBehaviors = 
 			mrep.nKeyExplicit = XkbNumKeys(new);
+		mrep.firstVModMapKey= new->min_key_code;
+		mrep.nVModMapKeys= XkbNumKeys(new);
 	    }
 	    else {
 		mrep.virtualMods= 0;
commit 7db55a0806c82bd4143c8bf1b8eb2b62e456ad9a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 20 14:38:25 2009 +1000

    dix: remove superfluous loop in change_modmap.
    
    A device can only be attached to a single master device. So instead of
    looping and searching for the master device, we can just use dev->u.master
    directly.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index c630088..1522145 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -275,14 +275,10 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap,
                     do_modmap_change(client, tmp, modmap);
         }
     }
-    else {
-        for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
-            if (tmp->isMaster && tmp->u.lastSlave == dev) {
-                /* If this fails, expect the results to be weird. */
-                if (check_modmap_change(client, tmp, modmap))
-                    do_modmap_change(client, tmp, modmap);
-            }
-        }
+    else if (dev->u.master && dev->u.master->u.lastSlave == dev) {
+        /* If this fails, expect the results to be weird. */
+        if (check_modmap_change(client, dev->u.master, modmap))
+            do_modmap_change(client, dev->u.master, modmap);
     }
 
     return Success;
commit cabff9007a4abad026b450a4aab155c7bcd94326
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri May 15 08:33:07 2009 +1000

    xfree86: treat other drivers as mouse drivers in the config.
    
    Historically, if no input device was referenced in the ServerLayout,
    the server would pick the first "mouse" device found in the xorg.conf.
    This patch gives evdev, synaptics, vmmouse and void the same status. If
    there is a section in the config file using this driver - use it as the core
    pointer.
    
    Device selection is in driver-order, not in config-order. If a "mouse"
    device is listed after a "synaptics" device, the "mouse" device gets
    preference. This replicates the original behaviour.
    
    This code only takes effect if AllowEmptyInput is off and there is no core
    pointer in the server layout.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 73235a9..165958b 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1090,8 +1090,8 @@ Bool xf86DRI2Enabled(void)
  *  2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
  *     the active ServerLayout.
  *  3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
- *  4. The first InputDevices that use the 'mouse' and 'keyboard' or 'kbd'
- *     drivers.
+ *  4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
+ *     driver (mouse, synaptics, evdev, vmmouse, void)
  *  5. Default devices with an empty (default) configuration.  These defaults
  *     will reference the 'mouse' and 'keyboard' drivers.
  */
@@ -1110,6 +1110,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     int count = 0;
     MessageType from = X_DEFAULT;
     int found = 0;
+    const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
+				   "void", NULL };
 
     /*
      * First check if a core pointer or core keyboard have been specified
@@ -1219,13 +1221,15 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	}
     }
 
-    /* 4. First pointer with 'mouse' as the driver. */
+    /* 4. First pointer with an allowed mouse driver. */
     if (!foundPointer && !xf86Info.allowEmptyInput) {
+	const char **driver = mousedrivers;
 	confInput = xf86findInput(CONF_IMPLICIT_POINTER,
 				  xf86configptr->conf_input_lst);
-	if (!confInput) {
-	    confInput = xf86findInputByDriver("mouse",
+	while (driver && !confInput) {
+	    confInput = xf86findInputByDriver(*driver,
 					      xf86configptr->conf_input_lst);
+	    driver++;
 	}
 	if (confInput) {
 	    foundPointer = TRUE;
@@ -1280,10 +1284,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
      * section ... deal.
      */
     for (devs = servlayoutp->inputs; devs && *devs; devs++) {
-	if (!strcmp((*devs)->driver, "void") || !strcmp((*devs)->driver, "mouse") ||
-            !strcmp((*devs)->driver, "vmmouse") || !strcmp((*devs)->driver, "evdev") ||
-            !strcmp((*devs)->driver, "synaptics")) {
-	    found = 1; break;
+	const char **driver = mousedrivers;
+	while(*driver) {
+	    if (!strcmp((*devs)->driver, *driver)) {
+		found = 1;
+		break;
+	    }
+	    driver++;
 	}
     }
     if (!found && !xf86Info.allowEmptyInput) {


More information about the xorg-commit mailing list