Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / CVE-2014-8xxx / 0000-glx-check-return.patch
1 From 61a292adf45405641de1c522a04c148e0a152acd Mon Sep 17 00:00:00 2001
2 From: Keith Packard <keithp@keithp.com>
3 Date: Thu, 9 Oct 2014 15:17:17 +0200
4 Subject: glx: check return from __glXGetAnswerBuffer
5
6 This function can return NULL; make sure every caller tests for that.
7
8 Reviewed-by: Adam Jackson <ajax@redhat.com>
9 Signed-off-by: Keith Packard <keithp@keithp.com>
10
11 diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c
12 index 329b2e6..f6cabef 100644
13 --- a/glx/indirect_dispatch.c
14 +++ b/glx/indirect_dispatch.c
15 @@ -2464,6 +2464,9 @@ __glXDisp_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
16 GLboolean answerBuffer[200];
17 GLboolean *residences =
18 __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
19 +
20 + if (residences == NULL)
21 + return BadAlloc;
22 retval =
23 glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
24 __glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
25 @@ -2488,6 +2491,9 @@ __glXDisp_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
26 GLboolean answerBuffer[200];
27 GLboolean *residences =
28 __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
29 +
30 + if (residences == NULL)
31 + return BadAlloc;
32 retval =
33 glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
34 __glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
35 @@ -2593,6 +2599,9 @@ __glXDisp_GenTextures(__GLXclientState * cl, GLbyte * pc)
36 GLuint *textures =
37 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
38 4);
39 +
40 + if (textures == NULL)
41 + return BadAlloc;
42 glGenTextures(n, textures);
43 __glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
44 error = Success;
45 @@ -2616,6 +2625,9 @@ __glXDisp_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
46 GLuint *textures =
47 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
48 4);
49 +
50 + if (textures == NULL)
51 + return BadAlloc;
52 glGenTextures(n, textures);
53 __glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
54 error = Success;
55 @@ -3883,6 +3895,9 @@ __glXDisp_GenQueries(__GLXclientState * cl, GLbyte * pc)
56 GLuint *ids =
57 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
58 4);
59 +
60 + if (ids == NULL)
61 + return BadAlloc;
62 GenQueries(n, ids);
63 __glXSendReply(cl->client, ids, n, 4, GL_TRUE, 0);
64 error = Success;
65 @@ -4253,6 +4268,9 @@ __glXDisp_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
66 GLuint *programs =
67 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
68 4);
69 +
70 + if (programs == NULL)
71 + return BadAlloc;
72 GenProgramsARB(n, programs);
73 __glXSendReply(cl->client, programs, n, 4, GL_TRUE, 0);
74 error = Success;
75 @@ -4630,6 +4648,10 @@ __glXDisp_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
76 GLuint *framebuffers =
77 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
78 4);
79 +
80 + if (framebuffers == NULL)
81 + return BadAlloc;
82 +
83 GenFramebuffers(n, framebuffers);
84 __glXSendReply(cl->client, framebuffers, n, 4, GL_TRUE, 0);
85 error = Success;
86 @@ -4655,6 +4677,9 @@ __glXDisp_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
87 GLuint *renderbuffers =
88 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
89 4);
90 +
91 + if (renderbuffers == NULL)
92 + return BadAlloc;
93 GenRenderbuffers(n, renderbuffers);
94 __glXSendReply(cl->client, renderbuffers, n, 4, GL_TRUE, 0);
95 error = Success;
96 diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c
97 index 647d0c9..c0bb64d 100644
98 --- a/glx/indirect_dispatch_swap.c
99 +++ b/glx/indirect_dispatch_swap.c
100 @@ -2731,6 +2731,9 @@ __glXDispSwap_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
101 GLboolean answerBuffer[200];
102 GLboolean *residences =
103 __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
104 +
105 + if (residences == NULL)
106 + return BadAlloc;
107 retval =
108 glAreTexturesResident(n,
109 (const GLuint *)
110 @@ -2759,6 +2762,9 @@ __glXDispSwap_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
111 GLboolean answerBuffer[200];
112 GLboolean *residences =
113 __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
114 +
115 + if (residences == NULL)
116 + return BadAlloc;
117 retval =
118 glAreTexturesResident(n,
119 (const GLuint *)
120 @@ -2878,6 +2884,9 @@ __glXDispSwap_GenTextures(__GLXclientState * cl, GLbyte * pc)
121 GLuint *textures =
122 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
123 4);
124 +
125 + if (textures == NULL)
126 + return BadAlloc;
127 glGenTextures(n, textures);
128 (void) bswap_32_array((uint32_t *) textures, n);
129 __glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
130 @@ -2903,6 +2912,9 @@ __glXDispSwap_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
131 GLuint *textures =
132 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
133 4);
134 +
135 + if (textures == NULL)
136 + return BadAlloc;
137 glGenTextures(n, textures);
138 (void) bswap_32_array((uint32_t *) textures, n);
139 __glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
140 @@ -4290,6 +4302,9 @@ __glXDispSwap_GenQueries(__GLXclientState * cl, GLbyte * pc)
141 GLuint *ids =
142 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
143 4);
144 + if (ids == NULL)
145 + return BadAlloc;
146 +
147 GenQueries(n, ids);
148 (void) bswap_32_array((uint32_t *) ids, n);
149 __glXSendReplySwap(cl->client, ids, n, 4, GL_TRUE, 0);
150 @@ -4697,6 +4712,9 @@ __glXDispSwap_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
151 GLuint *programs =
152 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
153 4);
154 + if (programs == NULL)
155 + return BadAlloc;
156 +
157 GenProgramsARB(n, programs);
158 (void) bswap_32_array((uint32_t *) programs, n);
159 __glXSendReplySwap(cl->client, programs, n, 4, GL_TRUE, 0);
160 @@ -5122,6 +5140,10 @@ __glXDispSwap_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
161 GLuint *framebuffers =
162 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
163 4);
164 +
165 + if (framebuffers == NULL)
166 + return BadAlloc;
167 +
168 GenFramebuffers(n, framebuffers);
169 (void) bswap_32_array((uint32_t *) framebuffers, n);
170 __glXSendReplySwap(cl->client, framebuffers, n, 4, GL_TRUE, 0);
171 @@ -5149,6 +5171,10 @@ __glXDispSwap_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
172 GLuint *renderbuffers =
173 __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
174 4);
175 +
176 + if (renderbuffers == NULL)
177 + return BadAlloc;
178 +
179 GenRenderbuffers(n, renderbuffers);
180 (void) bswap_32_array((uint32_t *) renderbuffers, n);
181 __glXSendReplySwap(cl->client, renderbuffers, n, 4, GL_TRUE, 0);
182 --
183 cgit v0.10.2
184