[Xcb] new SELinux protocol reply problem

Jamey Sharp jamey at minilop.net
Fri Feb 23 19:23:13 PST 2007

I'd have to think hard about whether it's your only problem, but I
believe this is at least *a* key problem:

On Fri, Feb 23, 2007 at 01:07:30PM -0600, Xavier Toth wrote:
>    len = strlen(ctx);
>    reply.response_type = X_Reply;
>    reply.length = (len + 3) >> 2;
>    reply.sequence = client->sequence;
>    reply.context_len = len;

In the X protocol, replies are always at least 32 bytes long, and their
length is measured in number of words *not counting* the fixed 32-byte
beginning. So if you encode the reply this way, the correct length is
	max(sizeof(reply) + len + 3 - 32, 0) >> 2

This is a bit confusing, and rather difficult for Xlib developers to
deal with correctly, so generally extension authors have chosen to pad
the fixed-length portion of the reply out to 32 bytes, and then start
any variable-length lists there. However, I see no reason why XCB
shouldn't handle it just fine, so I say encode it this way and to heck
with Xlib. ;-)

You've just illustrated why we need XCB-style code-generation in the X
server: these minor details like "the first 32 bytes don't count in the
reply length" can be encoded in the code generator, and extension
authors won't have to worry about making this kind of protocol error.

I think I've answered all the questions you asked; please ask again if
I've missed something.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20070223/0e4ee771/attachment.pgp

More information about the Xcb mailing list