Package: rdesktop
Version: 1.5.0-2+cvs20071006
Followup-For: Bug #445779

The problem was introduced with rev. 1.224 in rdesktop/xwin.c.

The problematic call is XGetPointerMapping, which is called with a 16 entry
buffer, with the expectation that XGetPointerMapping will return 16 as a
maximum value. XGetPointerMapping seems to return the number of available
mappings, regardless of the buffer size. In my case, this is 32. The 
for-loop will then overwrite more than 16 bytes of the
g_pointer_log_to_phys_map.

Restricting pointer_buttons to sizeof(g_pointer_log_to_phys_map) will fix
the problem. 

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: powerpc (ppc64)

Kernel: Linux 2.6.23-rc7-g7bae705e-dirty (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages rdesktop depends on:
ii  libc6                         2.6.1-5    GNU C Library: Shared libraries
ii  libssl0.9.8                   0.9.8f-1   SSL shared libraries
ii  libx11-6                      2:1.0.3-7  X11 client-side library

rdesktop recommends no packages.

-- no debconf information

*** rdesktop/diff
Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- xwin.c      12 Apr 2007 16:04:25 -0000      1.223
+++ xwin.c      14 May 2007 12:11:15 -0000      1.224
@@ -102,6 +102,9 @@
 static XIM g_IM;
 static XIC g_IC;
 static XModifierKeymap *g_mod_map;
+/* Maps logical (xmodmap -pp) pointing device buttons (0-based) back
+   to physical (1-based) indices. */
+static unsigned char g_pointer_log_to_phys_map[16];
 static Cursor g_current_cursor;
 static RD_HCURSOR g_null_cursor = NULL;
 static Atom g_protocol_atom, g_kill_atom;
@@ -1260,6 +1263,22 @@
        return out;
 }
 
+static void
+xwin_refresh_pointer_map(void)
+{
+       unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)];
+       int i, pointer_buttons;
+
+       pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, 
sizeof(phys_to_log_map));
+       for (i = 0; i < pointer_buttons; ++i)
+       {
+               /* This might produce multiple logical buttons mapping
+                  to a single physical one, but hey, that's
+                  life... */
+               g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1;
+       }
+}
+
 RD_BOOL
 get_key_state(unsigned int state, uint32 keysym)
 {
@@ -1614,6 +1633,7 @@
        g_width = (g_width + 3) & ~3;
 
        g_mod_map = XGetModifierMapping(g_display);
+       xwin_refresh_pointer_map();
 
        xkeymap_init();
 
@@ -1877,6 +1897,12 @@
 {
        uint16 button, flags = 0;
        g_last_gesturetime = xevent.xbutton.time;
+       /* Reverse the pointer button mapping, e.g. in the case of
+          "left-handed mouse mode"; the RDP session expects to
+          receive physical buttons (true in mstsc as well) and
+          logical button behavior depends on the remote desktop's own
+          mouse settings */
+       xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button 
- 1];
        button = xkeymap_translate_button(xevent.xbutton.button);
        if (button == 0)
                return;
@@ -2164,6 +2190,12 @@
                                        XFreeModifiermap(g_mod_map);
                                        g_mod_map = 
XGetModifierMapping(g_display);
                                }
+
+                               if (xevent.xmapping.request == MappingPointer)
+                               {
+                                       xwin_refresh_pointer_map();
+                               }
+
                                break;
 
                                /* clipboard stuff */

*** rdesktop/fix
Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.226
diff -u -r1.226 xwin.c
--- xwin.c      30 Aug 2007 04:47:36 -0000      1.226
+++ xwin.c      17 Oct 2007 16:09:22 -0000
@@ -1283,6 +1283,9 @@
        int i, pointer_buttons;
 
        pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, 
sizeof(phys_to_log_map));
+       if (pointer_buttons > sizeof(g_pointer_log_to_phys_map))
+               pointer_buttons = sizeof(g_pointer_log_to_phys_map);
+       
        for (i = 0; i < pointer_buttons; ++i)
        {
                /* This might produce multiple logical buttons mapping



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to