Gentoo Archives: gentoo-commits

From: "Chi-Thanh Christopher Nguyen (chithanh)" <chithanh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-libs/libXi/files: libXi-1.4.3-xiquerydevice.patch
Date: Wed, 16 Nov 2011 21:13:19
Message-Id: 20111116211307.B82342004C@flycatcher.gentoo.org
1 chithanh 11/11/16 21:13:07
2
3 Added: libXi-1.4.3-xiquerydevice.patch
4 Log:
5 Add patch to fix crash triggered by gtk+-3, bug #390693.
6
7 (Portage version: 2.2.0_alpha72/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 x11-libs/libXi/files/libXi-1.4.3-xiquerydevice.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-libs/libXi/files/libXi-1.4.3-xiquerydevice.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-libs/libXi/files/libXi-1.4.3-xiquerydevice.patch?rev=1.1&content-type=text/plain
14
15 Index: libXi-1.4.3-xiquerydevice.patch
16 ===================================================================
17 From 635c2c029b1e73311c3f650bcaf7eeb9e782134b Mon Sep 17 00:00:00 2001
18 From: Peter Hutterer <peter.hutterer@×××××.net>
19 Date: Wed, 17 Aug 2011 05:20:48 +0000
20 Subject: Handle unknown device classes.
21
22 If the server sends an unknown device class in response to an XIQueryDevice
23 call, no memory is allocated for these classes but we still write type
24 and sourceid as well as setting to->classes[i]. The latter causes multiple
25 classes to point to the same memory field.
26
27 Move the common code of assigning these three into the respective class type
28 handlers so to automatically skip any unknown classes.
29
30 Signed-off-by: Peter Hutterer <peter.hutterer@×××××.net>
31 ---
32 diff --git a/src/XExtInt.c b/src/XExtInt.c
33 index 86a780e..9e1ad19 100644
34 --- a/src/XExtInt.c
35 +++ b/src/XExtInt.c
36 @@ -98,7 +98,7 @@ extern int _XiGetDevicePresenceNotifyEvent(
37 Display * /* dpy */
38 );
39
40 -int copy_classes(XIDeviceInfo *to, xXIAnyInfo* from, int nclasses);
41 +int copy_classes(XIDeviceInfo *to, xXIAnyInfo* from, int *nclasses);
42 int size_classes(xXIAnyInfo* from, int nclasses);
43
44 static XExtensionInfo *xinput_info;
45 @@ -1448,30 +1448,29 @@ size_classes(xXIAnyInfo* from, int nclasses)
46 * |______________________^
47 */
48 _X_HIDDEN int
49 -copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
50 +copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
51 {
52 XIAnyClassInfo *any_lib;
53 xXIAnyInfo *any_wire;
54 void *ptr_lib;
55 char *ptr_wire;
56 int i, len;
57 + int cls_idx = 0;
58
59 if (!to->classes)
60 return -1;
61
62 ptr_wire = (char*)from;
63 ptr_lib = to->classes;
64 - to->classes = next_block(&ptr_lib, nclasses * sizeof(XIAnyClassInfo*));
65 + to->classes = next_block(&ptr_lib, *nclasses * sizeof(XIAnyClassInfo*));
66 + memset(to->classes, 0, sizeof(*nclasses * sizeof(XIAnyClassInfo*)));
67 len = 0; /* count wire length */
68
69 - for (i = 0; i < nclasses; i++)
70 + for (i = 0; i < *nclasses; i++)
71 {
72 any_lib = (XIAnyClassInfo*)ptr_lib;
73 any_wire = (xXIAnyInfo*)ptr_wire;
74
75 - to->classes[i] = any_lib;
76 - any_lib->type = any_wire->type;
77 - any_lib->sourceid = any_wire->sourceid;
78 switch(any_wire->type)
79 {
80 case XIButtonClass:
81 @@ -1485,6 +1484,8 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
82 cls_lib = next_block(&ptr_lib, sizeof(XIButtonClassInfo));
83 cls_wire = (xXIButtonInfo*)any_wire;
84
85 + cls_lib->type = cls_wire->type;
86 + cls_lib->sourceid = cls_wire->sourceid;
87 cls_lib->num_buttons = cls_wire->num_buttons;
88 size = ((((cls_wire->num_buttons + 7)/8) + 3)/4);
89 cls_lib->state.mask_len = size * 4;
90 @@ -1499,6 +1500,7 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
91 for (j = 0; j < cls_lib->num_buttons; j++)
92 cls_lib->labels[j] = *atoms++;
93
94 + to->classes[cls_idx++] = any_lib;
95 break;
96 }
97 case XIKeyClass:
98 @@ -1509,12 +1511,15 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
99 cls_lib = next_block(&ptr_lib, sizeof(XIKeyClassInfo));
100 cls_wire = (xXIKeyInfo*)any_wire;
101
102 + cls_lib->type = cls_wire->type;
103 + cls_lib->sourceid = cls_wire->sourceid;
104 cls_lib->num_keycodes = cls_wire->num_keycodes;
105 cls_lib->keycodes = next_block(&ptr_lib,
106 cls_lib->num_keycodes * sizeof(int));
107 memcpy(cls_lib->keycodes, &cls_wire[1],
108 cls_lib->num_keycodes);
109
110 + to->classes[cls_idx++] = any_lib;
111 break;
112 }
113 case XIValuatorClass:
114 @@ -1525,6 +1530,8 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
115 cls_lib = next_block(&ptr_lib, sizeof(XIValuatorClassInfo));
116 cls_wire = (xXIValuatorInfo*)any_wire;
117
118 + cls_lib->type = cls_wire->type;
119 + cls_lib->sourceid = cls_wire->sourceid;
120 cls_lib->number = cls_wire->number;
121 cls_lib->label = cls_wire->label;
122 cls_lib->resolution = cls_wire->resolution;
123 @@ -1534,12 +1541,16 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
124 /* FIXME: fractional parts */
125 cls_lib->mode = cls_wire->mode;
126
127 + to->classes[cls_idx++] = any_lib;
128 }
129 break;
130 }
131 len += any_wire->length * 4;
132 ptr_wire += any_wire->length * 4;
133 }
134 +
135 + /* we may have skipped unknown classes, reset nclasses */
136 + *nclasses = cls_idx;
137 return len;
138 }
139
140 @@ -1550,6 +1561,7 @@ wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XGenericEventCookie *cookie)
141 XIDeviceChangedEvent *out;
142 XIDeviceInfo info;
143 int len;
144 + int nclasses = in->num_classes;
145
146 len = size_classes((xXIAnyInfo*)&in[1], in->num_classes);
147
148 @@ -1564,13 +1576,13 @@ wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XGenericEventCookie *cookie)
149 out->deviceid = in->deviceid;
150 out->sourceid = in->sourceid;
151 out->reason = in->reason;
152 - out->num_classes = in->num_classes;
153
154 out->classes = (XIAnyClassInfo**)&out[1];
155
156 info.classes = out->classes;
157
158 - copy_classes(&info, (xXIAnyInfo*)&in[1], in->num_classes);
159 + copy_classes(&info, (xXIAnyInfo*)&in[1], &nclasses);
160 + out->num_classes = nclasses;
161
162 return 1;
163 }
164 diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c
165 index 4e2f392..c22aee1 100644
166 --- a/src/XIQueryDevice.c
167 +++ b/src/XIQueryDevice.c
168 @@ -29,7 +29,7 @@
169 #include <X11/extensions/extutil.h>
170 #include "XIint.h"
171
172 -extern int copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses);
173 +extern int copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses);
174 extern int size_classes(xXIAnyInfo* from, int nclasses);
175
176 XIDeviceInfo*
177 @@ -87,7 +87,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
178 ptr += ((wire->name_len + 3)/4) * 4;
179
180 lib->classes = Xmalloc(size_classes((xXIAnyInfo*)ptr, lib->num_classes));
181 - ptr += copy_classes(lib, (xXIAnyInfo*)ptr, lib->num_classes);
182 + ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &lib->num_classes);
183 }
184
185 Xfree(buf);
186 --
187 cgit v0.9.0.2-2-gbebe