Is SendRequest missing some padding?

Submitted by Alessandro Arzilli on Sept. 18, 2014, 12:29 p.m.

Details

Message ID 541AD00F.9080008@gmail.com
State New
Headers show

Commit Message

Alessandro Arzilli Sept. 18, 2014, 12:29 p.m.
Hello,
X.org X11 protocol documentation specifies that the fields 
AuthorizationProtocolName and AuthorizationProtocolData should be padded 
(http://www.x.org/releases/current/doc/xproto/x11protocol.html#Encoding::Connection_Setup), 
xproto.xml however doesn't mention this padding anywhere.

For context, I found this out because of this: 
https://github.com/BurntSushi/xgb/issues/24
I also ran a capture with wireshark and plugged the SetupRequest packet 
in this program (https://gist.github.com/aarzilli/fcd2a0094f89c29256a9) 
and it seems that xcb also isn't decoding the padding correctly (but 
maybe I'm doing it wrong?).

Also, just adding <pad align="4" /> after the two fields didn't work for 
me, I just got a compile error with libxcb-1.11.
This, much uglier, change did work:
---
Thank you,
Alessandro Arzilli

Patch hide | download patch | download mbox

--- xproto.xml.old	2014-09-18 13:34:17.794910423 +0200
+++ xproto.xml	2014-09-18 13:54:38.946273390 +0200
@@ -193,10 +193,28 @@ 
      <field type="CARD16" name="authorization_protocol_data_len" />
      <pad bytes="2" />
      <list type="char" name="authorization_protocol_name">
-      <fieldref>authorization_protocol_name_len</fieldref>
+      <op op="*">
+        <op op="/">
+          <op op="+">
+            <fieldref>authorization_protocol_name_len</fieldref>
+            <value>3</value>
+          </op>
+          <value>4</value>
+        </op>
+        <value>4</value>
+      </op>
      </list>
      <list type="char" name="authorization_protocol_data">
-      <fieldref>authorization_protocol_data_len</fieldref>
+      <op op="*">
+        <op op="/">
+          <op op="+">
+            <fieldref>authorization_protocol_data_len</fieldref>
+            <value>3</value>
+          </op>
+          <value>4</value>
+        </op>
+        <value>4</value>
+      </op>
      </list>
    </struct>
---


Comments

Alessandro Arzilli Sept. 19, 2014, 6:57 a.m.
On 09/18/2014 07:27 PM, chris@demorecorder.com wrote:
> Hello Alessandro,
>
> I think we should fix the problem in the generator with <pad align="4" />.
>
> Can you please try if <pad align="4" /> works with my newest patches which are not yet merged into upstream?
>
> You can get them with
> git clone http://infra-srv1.demorecorder.com/git/free-sw/xcb/libxcb/
> git clone http://infra-srv1.demorecorder.com/git/free-sw/xcb/proto/

I get the same error I got with libxcb-1.11.

With this SetupRequest:

===
   <struct name="SetupRequest">
     <field type="CARD8" name="byte_order" />
     <pad bytes="1" />
     <field type="CARD16" name="protocol_major_version" />
     <field type="CARD16" name="protocol_minor_version" />
     <field type="CARD16" name="authorization_protocol_name_len" />
     <field type="CARD16" name="authorization_protocol_data_len" />
     <pad bytes="2" />
     <list type="char" name="authorization_protocol_name">
       <fieldref>authorization_protocol_name_len</fieldref>
     </list>
     <pad align="4" />
     <list type="char" name="authorization_protocol_data">
       <fieldref>authorization_protocol_data_len</fieldref>
     </list>
     <pad align="4" />
   </struct>
===

I get this error:

===
xproto.c: In function 'xcb_setup_request_authorization_protocol_data_end':
xproto.c:629:36: error: 'None' undeclared (first use in this function)
      xcb_generic_iterator_t child = None;
                                     ^
xproto.c:629:36: note: each undeclared identifier is reported only once for each 
function it appears in
===

The error stays even if I remove the second "pad align". Just to be sure the 
branch you wanted me to check out is ParametrizedStruct-V3, right?

Alessandro Arzilli.