open-src/lib/libXinerama/CVE-2013-1985.patch
author Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
Wed, 15 May 2013 13:44:02 -0700
changeset 1345 d5dacbb8de2b
permissions -rw-r--r--
16673783 problem in X11/LIBRARIES 16674478 problem in X11/LIBRARIES
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1345
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     1
From 7ce3ce4be46087f9cc57cb415875abaaa961f734 Mon Sep 17 00:00:00 2001
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     2
From: Alan Coopersmith <[email protected]>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     3
Date: Sat, 4 May 2013 09:21:14 -0700
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     4
Subject: [PATCH:libXinerama 1/2] Use _XEatDataWords to avoid overflow of
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     5
 _XEatData calculations
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     6
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     7
rep.length is a CARD32, so rep.length << 2 could overflow in 32-bit builds
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     8
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     9
Signed-off-by: Alan Coopersmith <[email protected]>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    10
---
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    11
 configure.ac   |    6 ++++++
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    12
 src/Xinerama.c |   19 ++++++++++++++++++-
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    13
 2 files changed, 24 insertions(+), 1 deletion(-)
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    14
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    15
diff --git a/configure.ac b/configure.ac
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    16
index e335508..046a1aa 100644
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    17
--- a/configure.ac
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    18
+++ b/configure.ac
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    19
@@ -42,6 +42,12 @@ XORG_CHECK_MALLOC_ZERO
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    20
 # Obtain compiler/linker options for depedencies
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    21
 PKG_CHECK_MODULES(XINERAMA, x11 xext xextproto [xineramaproto >= 1.1.99.1])
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    22
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    23
+# Check for _XEatDataWords function that may be patched into older Xlib releases
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    24
+SAVE_LIBS="$LIBS"
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    25
+LIBS="$XINERAMA_LIBS"
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    26
+AC_CHECK_FUNCS([_XEatDataWords])
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    27
+LIBS="$SAVE_LIBS"
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    28
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    29
 # Allow checking code with lint, sparse, etc.
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    30
 XORG_WITH_LINT
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    31
 LINT_FLAGS="${LINT_FLAGS} ${XINERAMA_CFLAGS}"
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    32
diff --git a/src/Xinerama.c b/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    33
index 7d7e4d8..04189b6 100644
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    34
--- a/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    35
+++ b/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    36
@@ -23,6 +23,10 @@ dealings in this Software without prior written authorization from Digital
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    37
 Equipment Corporation.
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    38
 ******************************************************************/
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    39
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    40
+#ifdef HAVE_CONFIG_H
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    41
+# include "config.h"
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    42
+#endif
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    43
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    44
 #include <X11/Xlibint.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    45
 #include <X11/Xutil.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    46
 #include <X11/extensions/Xext.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    47
@@ -31,6 +35,19 @@ Equipment Corporation.
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    48
 #include <X11/extensions/panoramiXproto.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    49
 #include <X11/extensions/Xinerama.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    50
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    51
+#ifndef HAVE__XEATDATAWORDS
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    52
+#include <X11/Xmd.h>  /* for LONG64 on 64-bit platforms */
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    53
+#include <limits.h>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    54
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    55
+static inline void _XEatDataWords(Display *dpy, unsigned long n)
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    56
+{
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    57
+# ifndef LONG64
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    58
+    if (n >= (ULONG_MAX >> 2))
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    59
+        _XIOError(dpy);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    60
+# endif
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    61
+    _XEatData (dpy, n << 2);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    62
+}
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    63
+#endif
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    64
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    65
 static XExtensionInfo _panoramiX_ext_info_data;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    66
 static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    67
@@ -302,7 +319,7 @@ XineramaQueryScreens(
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    68
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    69
 	    *number = rep.number;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    70
 	} else
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    71
-	    _XEatData(dpy, rep.length << 2);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    72
+	    _XEatDataWords(dpy, rep.length);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    73
     } else {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    74
 	*number = 0;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    75
     }
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    76
-- 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    77
1.7.9.2
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    78
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    79
From 99c644fc8488657bdd106717df7446d606f9ef22 Mon Sep 17 00:00:00 2001
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    80
From: Alan Coopersmith <[email protected]>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    81
Date: Fri, 8 Mar 2013 19:55:55 -0800
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    82
Subject: [PATCH:libXinerama 2/2] integer overflow in XineramaQueryScreens()
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    83
 [CVE-2013-1985]
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    84
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    85
If the reported number of screens is too large, the calculations to
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    86
allocate memory for them may overflow, leaving us writing beyond the
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    87
bounds of the allocation.
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    88
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    89
Reported-by: Ilja Van Sprundel <[email protected]>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    90
Signed-off-by: Alan Coopersmith <[email protected]>
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    91
---
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    92
 src/Xinerama.c |   44 ++++++++++++++++++++++++++++----------------
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    93
 1 file changed, 28 insertions(+), 16 deletions(-)
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    94
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    95
diff --git a/src/Xinerama.c b/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    96
index 04189b6..67a35b5 100644
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    97
--- a/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    98
+++ b/src/Xinerama.c
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    99
@@ -303,24 +303,36 @@ XineramaQueryScreens(
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   100
 	return NULL;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   101
     }
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   102
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   103
-    if(rep.number) {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   104
-	if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number))) {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   105
+    /*
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   106
+     * rep.number is a CARD32 so could be as large as 2^32
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   107
+     * The X11 protocol limits the total screen size to 64k x 64k,
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   108
+     * and no screen can be smaller than a pixel.  While technically
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   109
+     * that means we could theoretically reach 2^32 screens, and that's
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   110
+     * not even taking overlap into account, Xorg is currently limited
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   111
+     * to 16 screens, and few known servers have a much higher limit,
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   112
+     * so 1024 seems more than enough to prevent both integer overflow
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   113
+     * and insane X server responses causing massive memory allocation.
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   114
+     */
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   115
+    if ((rep.number > 0) && (rep.number <= 1024))
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   116
+	scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   117
+    if (scrnInfo != NULL) {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   118
+	int i;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   119
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   120
+	for (i = 0; i < rep.number; i++) {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   121
 	    xXineramaScreenInfo scratch;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   122
-	    int i;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   123
-
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   124
-	    for(i = 0; i < rep.number; i++) {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   125
-		_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   126
-		scrnInfo[i].screen_number = i;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   127
-		scrnInfo[i].x_org 	  = scratch.x_org;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   128
-		scrnInfo[i].y_org 	  = scratch.y_org;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   129
-		scrnInfo[i].width 	  = scratch.width;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   130
-		scrnInfo[i].height 	  = scratch.height;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   131
-	    }
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   132
-
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   133
-	    *number = rep.number;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   134
-	} else
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   135
-	    _XEatDataWords(dpy, rep.length);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   136
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   137
+	    _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   138
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   139
+	    scrnInfo[i].screen_number = i;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   140
+	    scrnInfo[i].x_org	= scratch.x_org;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   141
+	    scrnInfo[i].y_org	= scratch.y_org;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   142
+	    scrnInfo[i].width	= scratch.width;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   143
+	    scrnInfo[i].height	= scratch.height;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   144
+	}
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   145
+
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   146
+	*number = rep.number;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   147
     } else {
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   148
+	_XEatDataWords(dpy, rep.length);
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   149
 	*number = 0;
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   150
     }
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   151
 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   152
-- 
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   153
1.7.9.2
d5dacbb8de2b 16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   154