Skip to content

Fix forwards-compatibility bug by allowing to specify expression that defines length of a struct

This MR fixes a forwards-compatibility bug that causes X server clients to crash when new XInput 2.4 GestureClass structs are sent within a response to XIQueryDevice request. X server has been patched in xorg/xserver@eb6f8dac to not send these new structs unless the client advertises XInput 2.4 support, but we still need to fix this issue as larger programs may have multiple versions of embedded libxcb.

The xcbproto part of this fix is here: xorg/proto/xcbproto!23 (merged)

This PR adjusts c_client.py to handle the new <length> element.

Regenerating the libxcb sources on top of xorg/proto/xcbproto!23 (merged) produces the following diff as expected (no other files were affected):

diff --git a/xinput.c b/xinput.c
index 9c3648f..086f0dc 100644
--- a/xinput.c
+++ b/xinput.c
@@ -10535,32 +10535,8 @@ xcb_input_device_class_data_sizeof (const void  *_buffer,
 int
 xcb_input_device_class_sizeof (const void  *_buffer)
 {
-    char *xcb_tmp = (char *)_buffer;
     const xcb_input_device_class_t *_aux = (xcb_input_device_class_t *)_buffer;
-    unsigned int xcb_buffer_len = 0;
-    unsigned int xcb_block_len = 0;
-    unsigned int xcb_pad = 0;
-    unsigned int xcb_align_to = 0;
-
-
-    xcb_block_len += sizeof(xcb_input_device_class_t);
-    xcb_tmp += xcb_block_len;
-    xcb_buffer_len += xcb_block_len;
-    xcb_block_len = 0;
-    /* data */
-    xcb_block_len += xcb_input_device_class_data_sizeof(xcb_tmp, _aux->type);
-    xcb_tmp += xcb_block_len;
-    xcb_align_to = ALIGNOF(char);
-    /* insert padding */
-    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
-    xcb_buffer_len += xcb_block_len + xcb_pad;
-    if (0 != xcb_pad) {
-        xcb_tmp += xcb_pad;
-        xcb_pad = 0;
-    }
-    xcb_block_len = 0;
-
-    return xcb_buffer_len;
+    return (_aux->len * 4);
 }

cc @alanc

Merge request reports