Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / CVE-2014-8xxx / 0021-glx-Be-more-strict-about-rejecting-invalid-image-siz.patch
CommitLineData
7217e0ca
ML
1From 74e31c4809dbfe437a3e2a53ee38658da1f3c8ed Mon Sep 17 00:00:00 2001
2From: Adam Jackson <ajax@redhat.com>
3Date: Mon, 10 Nov 2014 12:13:37 -0500
4Subject: [PATCH 21/33] glx: Be more strict about rejecting invalid image
5 sizes [CVE-2014-8093 2/6]
6
7Before this we'd just clamp the image size to 0, which was just
8hideously stupid; if the parameters were such that they'd overflow an
9integer, you'd allocate a small buffer, then pass huge values into (say)
10ReadPixels, and now you're scribbling over arbitrary server memory.
11
12Reviewed-by: Keith Packard <keithp@keithp.com>
13Reviewed-by: Julien Cristau <jcristau@debian.org>
14Reviewed-by: Michal Srb <msrb@suse.com>
15Reviewed-by: Andy Ritger <aritger@nvidia.com>
16Signed-off-by: Adam Jackson <ajax@redhat.com>
17Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
18---
19 glx/singlepix.c | 16 ++++++++--------
20 glx/singlepixswap.c | 16 ++++++++--------
21 2 files changed, 16 insertions(+), 16 deletions(-)
22
23diff --git a/glx/singlepix.c b/glx/singlepix.c
24index 506fdaa..8b6c261 100644
25--- a/glx/singlepix.c
26+++ b/glx/singlepix.c
27@@ -65,7 +65,7 @@ __glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
28 lsbFirst = *(GLboolean *) (pc + 25);
29 compsize = __glReadPixels_size(format, type, width, height);
30 if (compsize < 0)
31- compsize = 0;
32+ return BadLength;
33
34 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
35 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
36@@ -124,7 +124,7 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
37 compsize =
38 __glGetTexImage_size(target, level, format, type, width, height, depth);
39 if (compsize < 0)
40- compsize = 0;
41+ return BadLength;
42
43 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
44 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
45@@ -218,9 +218,9 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
46 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
47
48 if (compsize < 0)
49- compsize = 0;
50+ return BadLength;
51 if (compsize2 < 0)
52- compsize2 = 0;
53+ return BadLength;
54 compsize = __GLX_PAD(compsize);
55 compsize2 = __GLX_PAD(compsize2);
56
57@@ -296,7 +296,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
58 */
59 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
60 if (compsize < 0)
61- compsize = 0;
62+ return BadLength;
63
64 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
65 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
66@@ -365,7 +365,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
67 */
68 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
69 if (compsize < 0)
70- compsize = 0;
71+ return BadLength;
72
73 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
74 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
75@@ -426,7 +426,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
76
77 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
78 if (compsize < 0)
79- compsize = 0;
80+ return BadLength;
81
82 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
83 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
84@@ -491,7 +491,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
85 */
86 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
87 if (compsize < 0)
88- compsize = 0;
89+ return BadLength;
90
91 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
92 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
93diff --git a/glx/singlepixswap.c b/glx/singlepixswap.c
94index 8469101..8dc304f 100644
95--- a/glx/singlepixswap.c
96+++ b/glx/singlepixswap.c
97@@ -75,7 +75,7 @@ __glXDispSwap_ReadPixels(__GLXclientState * cl, GLbyte * pc)
98 lsbFirst = *(GLboolean *) (pc + 25);
99 compsize = __glReadPixels_size(format, type, width, height);
100 if (compsize < 0)
101- compsize = 0;
102+ return BadLength;
103
104 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
105 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
106@@ -144,7 +144,7 @@ __glXDispSwap_GetTexImage(__GLXclientState * cl, GLbyte * pc)
107 compsize =
108 __glGetTexImage_size(target, level, format, type, width, height, depth);
109 if (compsize < 0)
110- compsize = 0;
111+ return BadLength;
112
113 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
114 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
115@@ -252,9 +252,9 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
116 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
117
118 if (compsize < 0)
119- compsize = 0;
120+ return BadLength;
121 if (compsize2 < 0)
122- compsize2 = 0;
123+ return BadLength;
124 compsize = __GLX_PAD(compsize);
125 compsize2 = __GLX_PAD(compsize2);
126
127@@ -338,7 +338,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
128 */
129 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
130 if (compsize < 0)
131- compsize = 0;
132+ return BadLength;
133
134 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
135 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
136@@ -415,7 +415,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
137 */
138 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
139 if (compsize < 0)
140- compsize = 0;
141+ return BadLength;
142
143 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
144 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
145@@ -483,7 +483,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
146
147 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
148 if (compsize < 0)
149- compsize = 0;
150+ return BadLength;
151
152 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
153 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
154@@ -554,7 +554,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
155 */
156 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
157 if (compsize < 0)
158- compsize = 0;
159+ return BadLength;
160
161 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
162 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
163--
1641.7.9.2
165