[PATCH 06/11] glx: Implement GLX SetClientInfoARB protocol

Ian Romanick idr at freedesktop.org
Fri Dec 23 15:18:24 PST 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 glx/clientinfo.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/glx/clientinfo.c b/glx/clientinfo.c
index 3c0e7de..fb59a2a 100644
--- a/glx/clientinfo.c
+++ b/glx/clientinfo.c
@@ -26,15 +26,58 @@
 
 #include "glxserver.h"
 #include "indirect_dispatch.h"
+#include "glxbyteorder.h"
+#include "unpack.h"
 
 int __glXDisp_SetClientInfoARB(__GLXclientState *cl, GLbyte *pc)
 {
-    return BadRequest;
+    xGLXSetClientInfoARBReq *req = (xGLXSetClientInfoARBReq *) pc;
+    char *gl_extensions;
+    char *glx_extensions;
+
+    /* Verify that the size of the packet matches the size inferred from the
+     * sizes specified for the various fields.
+     */
+    const unsigned expected_size = sz_xGLXSetClientInfoARBReq
+	+ (req->numVersions * 8)
+	+ __GLX_PAD(req->numGLExtensionBytes)
+	+ __GLX_PAD(req->numGLXExtensionBytes);
+
+    if (req->length != (expected_size / 4))
+	return BadLength;
+
+    /* Verify that the actual length of the GL extension string matches what's
+     * encoded in protocol packet.
+     */
+    gl_extensions = (char *) (req + 1) + (req->numVersions * 8);
+    if (req->numGLExtensionBytes != 0
+	&& memchr(gl_extensions, 0, __GLX_PAD(req->numGLExtensionBytes)) == NULL)
+	return BadLength;
+
+    /* Verify that the actual length of the GLX extension string matches
+     * what's encoded in protocol packet.
+     */
+    glx_extensions = gl_extensions + __GLX_PAD(req->numGLExtensionBytes);
+    if (req->numGLXExtensionBytes != 0 
+	&& memchr(glx_extensions, 0, __GLX_PAD(req->numGLXExtensionBytes)) == NULL)
+	return BadLength;
+
+    free(cl->GLClientextensions);
+    cl->GLClientextensions = strdup(gl_extensions);
+
+    return 0;
 }
 
 int __glXDispSwap_SetClientInfoARB(__GLXclientState *cl, GLbyte *pc)
 {
-    return BadRequest;
+    xGLXSetClientInfoARBReq *req = (xGLXSetClientInfoARBReq *) pc;
+
+    req->length = bswap_16(req->length);
+    req->numVersions = bswap_32(req->numVersions);
+    req->numGLExtensionBytes = bswap_32(req->numGLExtensionBytes);
+    req->numGLXExtensionBytes = bswap_32(req->numGLXExtensionBytes);
+    
+    return __glXDisp_SetClientInfoARB(cl, pc);
 }
 
 int __glXDisp_SetClientInfo2ARB(__GLXclientState *cl, GLbyte *pc)
-- 
1.7.6.4



More information about the xorg-devel mailing list