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

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2013-1995.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 memory size calculations from signedness issues
 
3
Origin: upstream, http://cgit.freedesktop.org/xorg/lib/libXi/commit/?id=81b4df8ac6aa1520c41c3526961014a6f115cc46
 
4
 
 
5
Index: libxi-1.6.99.1/src/XListDev.c
 
6
===================================================================
 
7
--- libxi-1.6.99.1.orig/src/XListDev.c  2013-05-29 10:06:41.916395291 -0400
 
8
+++ libxi-1.6.99.1/src/XListDev.c       2013-05-29 10:06:56.004395156 -0400
 
9
@@ -73,7 +73,7 @@
 
10
     return ((base_size + padsize - 1)/padsize) * padsize;
 
11
 }
 
12
 
 
13
-static int
 
14
+static size_t
 
15
 SizeClassInfo(xAnyClassPtr *any, int num_classes)
 
16
 {
 
17
     int size = 0;
 
18
@@ -170,7 +170,7 @@
 
19
     register Display   *dpy,
 
20
     int                        *ndevices)
 
21
 {
 
22
-    int size;
 
23
+    size_t size;
 
24
     xListInputDevicesReq *req;
 
25
     xListInputDevicesReply rep;
 
26
     xDeviceInfo *list, *slist = NULL;
 
27
@@ -178,7 +178,7 @@
 
28
     XDeviceInfo *clist = NULL;
 
29
     xAnyClassPtr any, sav_any;
 
30
     XAnyClassPtr Any;
 
31
-    char *nptr, *Nptr;
 
32
+    unsigned char *nptr, *Nptr;
 
33
     int i;
 
34
     unsigned long rlen;
 
35
     XExtDisplayInfo *info = XInput_find_display(dpy);
 
36
@@ -217,9 +217,12 @@
 
37
             size += SizeClassInfo(&any, (int)list->num_classes);
 
38
        }
 
39
 
 
40
-       for (i = 0, nptr = (char *)any; i < *ndevices; i++) {
 
41
+       Nptr = ((unsigned char *)list) + rlen + 1;
 
42
+       for (i = 0, nptr = (unsigned char *)any; i < *ndevices; i++) {
 
43
            size += *nptr + 1;
 
44
            nptr += (*nptr + 1);
 
45
+           if (nptr > Nptr)
 
46
+               goto out;
 
47
        }
 
48
 
 
49
        clist = (XDeviceInfoPtr) Xmalloc(size);
 
50
@@ -245,8 +248,8 @@
 
51
        }
 
52
 
 
53
        clist = sclist;
 
54
-       nptr = (char *)any;
 
55
-       Nptr = (char *)Any;
 
56
+       nptr = (unsigned char *)any;
 
57
+       Nptr = (unsigned char *)Any;
 
58
        for (i = 0; i < *ndevices; i++, clist++) {
 
59
            clist->name = (char *)Nptr;
 
60
            memcpy(Nptr, nptr + 1, *nptr);
 
61
@@ -256,6 +259,7 @@
 
62
        }
 
63
     }
 
64
 
 
65
+  out:
 
66
     XFree((char *)slist);
 
67
     UnlockDisplay(dpy);
 
68
     SyncHandle();