Blame SOURCES/0019-Add-REQUEST_FIXED_SIZE-testcases-to-test-misc.c.patch

0fd959
From 19434b3ce4ed730d71155ba3edf44f68979ddb28 Mon Sep 17 00:00:00 2001
0fd959
From: Alan Coopersmith <alan.coopersmith@oracle.com>
0fd959
Date: Sun, 9 Feb 2014 22:42:47 -0800
0fd959
Subject: [PATCH 19/33] Add REQUEST_FIXED_SIZE testcases to test/misc.c
0fd959
0fd959
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
0fd959
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
0fd959
Signed-off-by: Fedora X Ninjas <x@fedoraproject.org>
0fd959
---
0fd959
 test/misc.c | 37 +++++++++++++++++++++++++++++++++++++
0fd959
 1 file changed, 37 insertions(+)
0fd959
0fd959
diff --git a/test/misc.c b/test/misc.c
0fd959
index dd792e6..66330a1 100644
0fd959
--- a/test/misc.c
0fd959
+++ b/test/misc.c
0fd959
@@ -28,6 +28,8 @@
0fd959
 #include <stdint.h>
0fd959
 #include "misc.h"
0fd959
 #include "scrnintstr.h"
0fd959
+#include "dix.h"
0fd959
+#include "dixstruct.h"
0fd959
 
0fd959
 ScreenInfo screenInfo;
0fd959
 
0fd959
@@ -155,11 +157,46 @@ dix_update_desktop_dimensions(void)
0fd959
     assert_dimensions(-w2, -h2, w2, h2);
0fd959
 }
0fd959
 
0fd959
+static int
0fd959
+dix_request_fixed_size_overflow(ClientRec *client)
0fd959
+{
0fd959
+    xReq req = { 0 };
0fd959
+
0fd959
+    client->req_len = req.length = 1;
0fd959
+    REQUEST_FIXED_SIZE(req, SIZE_MAX);
0fd959
+    return Success;
0fd959
+}
0fd959
+
0fd959
+static int
0fd959
+dix_request_fixed_size_match(ClientRec *client)
0fd959
+{
0fd959
+    xReq req = { 0 };
0fd959
+
0fd959
+    client->req_len = req.length = 9;
0fd959
+    REQUEST_FIXED_SIZE(req, 30);
0fd959
+    return Success;
0fd959
+}
0fd959
+
0fd959
+static void
0fd959
+dix_request_size_checks(void)
0fd959
+{
0fd959
+    ClientRec client = { 0 };
0fd959
+    int rc;
0fd959
+
0fd959
+    rc = dix_request_fixed_size_overflow(&client);
0fd959
+    assert(rc == BadLength);
0fd959
+
0fd959
+    rc = dix_request_fixed_size_match(&client);
0fd959
+    assert(rc == Success);
0fd959
+}
0fd959
+
0fd959
+
0fd959
 int
0fd959
 main(int argc, char **argv)
0fd959
 {
0fd959
     dix_version_compare();
0fd959
     dix_update_desktop_dimensions();
0fd959
+    dix_request_size_checks();
0fd959
 
0fd959
     return 0;
0fd959
 }
0fd959
-- 
0fd959
1.9.3
0fd959