From 8436c920953f288aea2d6d5f370f8eaaaef82d97 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 15 Mar 2012 11:51:41 +1000 Subject: Fix wrong button label and mask copy on OS X Regression introduced in c1a5a70b51f12dedf354102217c7cd4247ed3a4b. If double-padding is applied, the length of the mask on the wire may be smaller than libXi's mask_len. When copying, only the wire length must be copied, with the remainder set to 0. When advancing to the button labels, the wire length matters, not libXi's internal length. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston Tested-by: Jeremy Huddleston --- src/XExtInt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/XExtInt.c') diff --git a/src/XExtInt.c b/src/XExtInt.c index 89c0894..0c64f9a 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -1610,12 +1610,14 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses) int struct_size; int state_size; int labels_size; + int wire_mask_size; cls_wire = (xXIButtonInfo*)any_wire; sizeXIButtonClassType(cls_wire->num_buttons, &struct_size, &state_size, &labels_size); cls_lib = next_block(&ptr_lib, struct_size); + wire_mask_size = ((cls_wire->num_buttons + 7)/8 + 3)/4 * 4; cls_lib->type = cls_wire->type; cls_lib->sourceid = cls_wire->sourceid; @@ -1623,10 +1625,14 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses) cls_lib->state.mask_len = state_size; cls_lib->state.mask = next_block(&ptr_lib, state_size); memcpy(cls_lib->state.mask, &cls_wire[1], - cls_lib->state.mask_len); + wire_mask_size); + if (state_size != wire_mask_size) + memset(&cls_lib->state.mask[wire_mask_size], 0, + state_size - wire_mask_size); cls_lib->labels = next_block(&ptr_lib, labels_size); - atoms =(uint32_t*)((char*)&cls_wire[1] + cls_lib->state.mask_len); + + atoms =(uint32_t*)((char*)&cls_wire[1] + wire_mask_size); for (j = 0; j < cls_lib->num_buttons; j++) cls_lib->labels[j] = *atoms++; -- cgit v1.2.3