~ubuntu-branches/ubuntu/trusty/libxi/trusty-security

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2013-1998.patch

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-06-05 15:41:47 UTC
  • mfrom: (0.1.24 lucid)
  • Revision ID: package-import@ubuntu.com-20130605154147-2fs59u034h4dfhhk
Tags: 2:1.6.99.1-0ubuntu4
* SECURITY UPDATE: denial of service and possible code execution via
  incorrect memory size calculations
  - debian/patches/CVE-2013-1984.patch: fix multiple integer overflows.
  - CVE-2013-1984
* SECURITY UPDATE: denial of service and possible code execution via
  incorrect memory size calculations from signedness issues
  - debian/patches/CVE-2013-1995.patch: fix signedness issues in
    src/XListDev.c.
  - CVE-2013-1995
* SECURITY UPDATE: denial of service and possible code execution via
  incorrect length and bounds checking
  - debian/patches/CVE-2013-1998.patch: properly check lengths and
    indexes in src/XGetBMap.c, src/XIPassiveGrab.c, src/XQueryDv.c.
  - CVE-2013-1998

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: fix denial of service and possible code execution via
 
2
 incorrect length and bounds checking
 
3
Origin: upstream, http://cgit.freedesktop.org/xorg/lib/libXi/commit/?id=f3e08e4fbe40016484ba795feecf1a742170ffc1
 
4
Origin: upstream, http://cgit.freedesktop.org/xorg/lib/libXi/commit/?id=91434737f592e8f5cc1762383882a582b55fc03a
 
5
Origin: upstream, http://cgit.freedesktop.org/xorg/lib/libXi/commit/?id=5398ac0797f7516f2c9b8f2869a6c6d071437352
 
6
 
 
7
Index: libxi-1.6.99.1/src/XGetBMap.c
 
8
===================================================================
 
9
--- libxi-1.6.99.1.orig/src/XGetBMap.c  2013-05-29 10:17:11.112389290 -0400
 
10
+++ libxi-1.6.99.1/src/XGetBMap.c       2013-05-29 10:17:11.108389290 -0400
 
11
@@ -60,6 +60,7 @@
 
12
 #include <X11/extensions/XInput.h>
 
13
 #include <X11/extensions/extutil.h>
 
14
 #include "XIint.h"
 
15
+#include <limits.h>
 
16
 
 
17
 #ifdef MIN     /* some systems define this in <sys/param.h> */
 
18
 #undef MIN
 
19
@@ -75,7 +76,6 @@
 
20
 {
 
21
     int status = 0;
 
22
     unsigned char mapping[256];        /* known fixed size */
 
23
-    long nbytes;
 
24
     XExtDisplayInfo *info = XInput_find_display(dpy);
 
25
 
 
26
     register xGetDeviceButtonMappingReq *req;
 
27
@@ -92,13 +92,18 @@
 
28
 
 
29
     status = _XReply(dpy, (xReply *) & rep, 0, xFalse);
 
30
     if (status == 1) {
 
31
-       nbytes = (long)rep.length << 2;
 
32
-       _XRead(dpy, (char *)mapping, nbytes);
 
33
-
 
34
-       /* don't return more data than the user asked for. */
 
35
-       if (rep.nElts)
 
36
-           memcpy((char *)map, (char *)mapping, MIN((int)rep.nElts, nmap));
 
37
-       status = rep.nElts;
 
38
+       if (rep.length <= (sizeof(mapping) >> 2)) {
 
39
+           unsigned long nbytes = rep.length << 2;
 
40
+           _XRead(dpy, (char *)mapping, nbytes);
 
41
+
 
42
+           /* don't return more data than the user asked for. */
 
43
+           if (rep.nElts)
 
44
+               memcpy(map, mapping, MIN((int)rep.nElts, nmap));
 
45
+           status = rep.nElts;
 
46
+       } else {
 
47
+           _XEatDataWords(dpy, rep.length);
 
48
+           status = 0;
 
49
+       }
 
50
     } else
 
51
        status = 0;
 
52
     UnlockDisplay(dpy);
 
53
Index: libxi-1.6.99.1/src/XIPassiveGrab.c
 
54
===================================================================
 
55
--- libxi-1.6.99.1.orig/src/XIPassiveGrab.c     2013-05-29 10:17:11.112389290 -0400
 
56
+++ libxi-1.6.99.1/src/XIPassiveGrab.c  2013-05-29 10:17:11.108389290 -0400
 
57
@@ -88,7 +88,7 @@
 
58
         return -1;
 
59
     _XRead(dpy, (char*)failed_mods, reply.num_modifiers * sizeof(xXIGrabModifierInfo));
 
60
 
 
61
-    for (i = 0; i < reply.num_modifiers; i++)
 
62
+    for (i = 0; i < reply.num_modifiers && i < num_modifiers; i++)
 
63
     {
 
64
         modifiers_inout[i].status = failed_mods[i].status;
 
65
         modifiers_inout[i].modifiers = failed_mods[i].modifiers;
 
66
Index: libxi-1.6.99.1/src/XQueryDv.c
 
67
===================================================================
 
68
--- libxi-1.6.99.1.orig/src/XQueryDv.c  2013-05-29 10:17:11.060389291 -0400
 
69
+++ libxi-1.6.99.1/src/XQueryDv.c       2013-05-29 10:17:29.156389118 -0400
 
70
@@ -59,6 +59,7 @@
 
71
 #include <X11/extensions/XInput.h>
 
72
 #include <X11/extensions/extutil.h>
 
73
 #include "XIint.h"
 
74
+#include <limits.h>
 
75
 
 
76
 XDeviceState *
 
77
 XQueryDeviceState(
 
78
@@ -66,8 +67,8 @@
 
79
     XDevice            *dev)
 
80
 {
 
81
     int i, j;
 
82
-    int rlen;
 
83
-    int size = 0;
 
84
+    unsigned long rlen;
 
85
+    size_t size = 0;
 
86
     xQueryDeviceStateReq *req;
 
87
     xQueryDeviceStateReply rep;
 
88
     XDeviceState *state = NULL;
 
89
@@ -87,9 +88,11 @@
 
90
     if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
 
91
         goto out;
 
92
 
 
93
-    rlen = rep.length << 2;
 
94
-    if (rlen > 0) {
 
95
-       data = Xmalloc(rlen);
 
96
+    if (rep.length > 0) {
 
97
+       if (rep.length < (INT_MAX >> 2)) {
 
98
+           rlen = (unsigned long) rep.length << 2;
 
99
+           data = Xmalloc(rlen);
 
100
+       }
 
101
        if (!data) {
 
102
            _XEatDataWords(dpy, rep.length);
 
103
            goto out;
 
104
@@ -97,6 +100,10 @@
 
105
        _XRead(dpy, data, rlen);
 
106
 
 
107
        for (i = 0, any = (XInputClass *) data; i < (int)rep.num_classes; i++) {
 
108
+           if (any->length > rlen)
 
109
+               goto out;
 
110
+           rlen -= any->length;
 
111
+
 
112
            switch (any->class) {
 
113
            case KeyClass:
 
114
                size += sizeof(XKeyState);