trinity: not available on musl
[buildroot-gz.git] / package / jasper / 0006-fix-CVE-2014-8158.patch
blob8413d2ef936360b31b077ed7d760e7548d8ed9ef
1 Fix CVE-2014-8158 - unrestricted stack memory use in jpc_qmfb.c
2 From https://bugzilla.redhat.com/show_bug.cgi?id=1179298
4 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
6 diff -up jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c.CVE-2014-8158 jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c
7 --- jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c.CVE-2014-8158 2015-01-19 17:25:28.730195502 +0100
8 +++ jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c 2015-01-19 17:27:20.214663127 +0100
9 @@ -306,11 +306,7 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
12 int bufsize = JPC_CEILDIVPOW2(numcols, 1);
13 -#if !defined(HAVE_VLA)
14 jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
15 -#else
16 - jpc_fix_t splitbuf[bufsize];
17 -#endif
18 jpc_fix_t *buf = splitbuf;
19 register jpc_fix_t *srcptr;
20 register jpc_fix_t *dstptr;
21 @@ -318,7 +314,6 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
22 register int m;
23 int hstartcol;
25 -#if !defined(HAVE_VLA)
26 /* Get a buffer. */
27 if (bufsize > QMFB_SPLITBUFSIZE) {
28 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
29 @@ -326,7 +321,6 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
30 abort();
33 -#endif
35 if (numcols >= 2) {
36 hstartcol = (numcols + 1 - parity) >> 1;
37 @@ -360,12 +354,10 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
41 -#if !defined(HAVE_VLA)
42 /* If the split buffer was allocated on the heap, free this memory. */
43 if (buf != splitbuf) {
44 jas_free(buf);
46 -#endif
50 @@ -374,11 +366,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
53 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
54 -#if !defined(HAVE_VLA)
55 jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
56 -#else
57 - jpc_fix_t splitbuf[bufsize];
58 -#endif
59 jpc_fix_t *buf = splitbuf;
60 register jpc_fix_t *srcptr;
61 register jpc_fix_t *dstptr;
62 @@ -386,7 +374,6 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
63 register int m;
64 int hstartcol;
66 -#if !defined(HAVE_VLA)
67 /* Get a buffer. */
68 if (bufsize > QMFB_SPLITBUFSIZE) {
69 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
70 @@ -394,7 +381,6 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
71 abort();
74 -#endif
76 if (numrows >= 2) {
77 hstartcol = (numrows + 1 - parity) >> 1;
78 @@ -428,12 +414,10 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
82 -#if !defined(HAVE_VLA)
83 /* If the split buffer was allocated on the heap, free this memory. */
84 if (buf != splitbuf) {
85 jas_free(buf);
87 -#endif
91 @@ -442,11 +426,7 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
94 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
95 -#if !defined(HAVE_VLA)
96 jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE];
97 -#else
98 - jpc_fix_t splitbuf[bufsize * JPC_QMFB_COLGRPSIZE];
99 -#endif
100 jpc_fix_t *buf = splitbuf;
101 jpc_fix_t *srcptr;
102 jpc_fix_t *dstptr;
103 @@ -457,7 +437,6 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
104 int m;
105 int hstartcol;
107 -#if !defined(HAVE_VLA)
108 /* Get a buffer. */
109 if (bufsize > QMFB_SPLITBUFSIZE) {
110 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
111 @@ -465,7 +444,6 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
112 abort();
115 -#endif
117 if (numrows >= 2) {
118 hstartcol = (numrows + 1 - parity) >> 1;
119 @@ -517,12 +495,10 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
123 -#if !defined(HAVE_VLA)
124 /* If the split buffer was allocated on the heap, free this memory. */
125 if (buf != splitbuf) {
126 jas_free(buf);
128 -#endif
132 @@ -531,11 +507,7 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
135 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
136 -#if !defined(HAVE_VLA)
137 jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE];
138 -#else
139 - jpc_fix_t splitbuf[bufsize * numcols];
140 -#endif
141 jpc_fix_t *buf = splitbuf;
142 jpc_fix_t *srcptr;
143 jpc_fix_t *dstptr;
144 @@ -546,7 +518,6 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
145 int m;
146 int hstartcol;
148 -#if !defined(HAVE_VLA)
149 /* Get a buffer. */
150 if (bufsize > QMFB_SPLITBUFSIZE) {
151 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
152 @@ -554,7 +525,6 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
153 abort();
156 -#endif
158 if (numrows >= 2) {
159 hstartcol = (numrows + 1 - parity) >> 1;
160 @@ -606,12 +576,10 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
164 -#if !defined(HAVE_VLA)
165 /* If the split buffer was allocated on the heap, free this memory. */
166 if (buf != splitbuf) {
167 jas_free(buf);
169 -#endif
173 @@ -619,18 +587,13 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
176 int bufsize = JPC_CEILDIVPOW2(numcols, 1);
177 -#if !defined(HAVE_VLA)
178 jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
179 -#else
180 - jpc_fix_t joinbuf[bufsize];
181 -#endif
182 jpc_fix_t *buf = joinbuf;
183 register jpc_fix_t *srcptr;
184 register jpc_fix_t *dstptr;
185 register int n;
186 int hstartcol;
188 -#if !defined(HAVE_VLA)
189 /* Allocate memory for the join buffer from the heap. */
190 if (bufsize > QMFB_JOINBUFSIZE) {
191 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
192 @@ -638,7 +601,6 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
193 abort();
196 -#endif
198 hstartcol = (numcols + 1 - parity) >> 1;
200 @@ -670,12 +632,10 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
201 ++srcptr;
204 -#if !defined(HAVE_VLA)
205 /* If the join buffer was allocated on the heap, free this memory. */
206 if (buf != joinbuf) {
207 jas_free(buf);
209 -#endif
213 @@ -684,18 +644,13 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
216 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
217 -#if !defined(HAVE_VLA)
218 jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
219 -#else
220 - jpc_fix_t joinbuf[bufsize];
221 -#endif
222 jpc_fix_t *buf = joinbuf;
223 register jpc_fix_t *srcptr;
224 register jpc_fix_t *dstptr;
225 register int n;
226 int hstartcol;
228 -#if !defined(HAVE_VLA)
229 /* Allocate memory for the join buffer from the heap. */
230 if (bufsize > QMFB_JOINBUFSIZE) {
231 if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
232 @@ -703,7 +658,6 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
233 abort();
236 -#endif
238 hstartcol = (numrows + 1 - parity) >> 1;
240 @@ -735,12 +689,10 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
241 ++srcptr;
244 -#if !defined(HAVE_VLA)
245 /* If the join buffer was allocated on the heap, free this memory. */
246 if (buf != joinbuf) {
247 jas_free(buf);
249 -#endif
253 @@ -749,11 +701,7 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
256 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
257 -#if !defined(HAVE_VLA)
258 jpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];
259 -#else
260 - jpc_fix_t joinbuf[bufsize * JPC_QMFB_COLGRPSIZE];
261 -#endif
262 jpc_fix_t *buf = joinbuf;
263 jpc_fix_t *srcptr;
264 jpc_fix_t *dstptr;
265 @@ -763,7 +711,6 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
266 register int i;
267 int hstartcol;
269 -#if !defined(HAVE_VLA)
270 /* Allocate memory for the join buffer from the heap. */
271 if (bufsize > QMFB_JOINBUFSIZE) {
272 if (!(buf = jas_alloc2(bufsize, JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
273 @@ -771,7 +718,6 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
274 abort();
277 -#endif
279 hstartcol = (numrows + 1 - parity) >> 1;
281 @@ -821,12 +767,10 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
282 srcptr += JPC_QMFB_COLGRPSIZE;
285 -#if !defined(HAVE_VLA)
286 /* If the join buffer was allocated on the heap, free this memory. */
287 if (buf != joinbuf) {
288 jas_free(buf);
290 -#endif
294 @@ -835,11 +779,7 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
297 int bufsize = JPC_CEILDIVPOW2(numrows, 1);
298 -#if !defined(HAVE_VLA)
299 jpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];
300 -#else
301 - jpc_fix_t joinbuf[bufsize * numcols];
302 -#endif
303 jpc_fix_t *buf = joinbuf;
304 jpc_fix_t *srcptr;
305 jpc_fix_t *dstptr;
306 @@ -849,7 +789,6 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
307 register int i;
308 int hstartcol;
310 -#if !defined(HAVE_VLA)
311 /* Allocate memory for the join buffer from the heap. */
312 if (bufsize > QMFB_JOINBUFSIZE) {
313 if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) {
314 @@ -857,7 +796,6 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
315 abort();
318 -#endif
320 hstartcol = (numrows + 1 - parity) >> 1;
322 @@ -907,12 +845,10 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
323 srcptr += numcols;
326 -#if !defined(HAVE_VLA)
327 /* If the join buffer was allocated on the heap, free this memory. */
328 if (buf != joinbuf) {
329 jas_free(buf);
331 -#endif