Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / CVE-2014-8xxx / 0019-Add-REQUEST_FIXED_SIZE-testcases-to-test-misc.c.patch
1 From d4934a8fb4fab54d39c42ca445687985fe4410cd Mon Sep 17 00:00:00 2001
2 From: Alan Coopersmith <alan.coopersmith@oracle.com>
3 Date: Sun, 9 Feb 2014 22:42:47 -0800
4 Subject: [PATCH 19/33] Add REQUEST_FIXED_SIZE testcases to test/misc.c
5
6 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
7 Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 ---
9 test/misc.c | 37 +++++++++++++++++++++++++++++++++++++
10 1 file changed, 37 insertions(+)
11
12 diff --git a/test/misc.c b/test/misc.c
13 index dd792e6..66330a1 100644
14 --- a/test/misc.c
15 +++ b/test/misc.c
16 @@ -28,6 +28,8 @@
17 #include <stdint.h>
18 #include "misc.h"
19 #include "scrnintstr.h"
20 +#include "dix.h"
21 +#include "dixstruct.h"
22
23 ScreenInfo screenInfo;
24
25 @@ -155,11 +157,46 @@ dix_update_desktop_dimensions(void)
26 assert_dimensions(-w2, -h2, w2, h2);
27 }
28
29 +static int
30 +dix_request_fixed_size_overflow(ClientRec *client)
31 +{
32 + xReq req = { 0 };
33 +
34 + client->req_len = req.length = 1;
35 + REQUEST_FIXED_SIZE(req, SIZE_MAX);
36 + return Success;
37 +}
38 +
39 +static int
40 +dix_request_fixed_size_match(ClientRec *client)
41 +{
42 + xReq req = { 0 };
43 +
44 + client->req_len = req.length = 9;
45 + REQUEST_FIXED_SIZE(req, 30);
46 + return Success;
47 +}
48 +
49 +static void
50 +dix_request_size_checks(void)
51 +{
52 + ClientRec client = { 0 };
53 + int rc;
54 +
55 + rc = dix_request_fixed_size_overflow(&client);
56 + assert(rc == BadLength);
57 +
58 + rc = dix_request_fixed_size_match(&client);
59 + assert(rc == Success);
60 +}
61 +
62 +
63 int
64 main(int argc, char **argv)
65 {
66 dix_version_compare();
67 dix_update_desktop_dimensions();
68 + dix_request_size_checks();
69
70 return 0;
71 }
72 --
73 1.7.9.2
74