978a2f
--- jasper-1.900.1.orig/src/libjasper/jp2/jp2_dec.c	2014-12-11 14:06:44.000000000 +0100
978a2f
+++ jasper-1.900.1/src/libjasper/jp2/jp2_dec.c	2014-12-11 14:06:26.000000000 +0100
978a2f
@@ -386,6 +386,11 @@ jas_image_t *jp2_decode(jas_stream_t *in
978a2f
 	/* Determine the type of each component. */
978a2f
 	if (dec->cdef) {
978a2f
 		for (i = 0; i < dec->numchans; ++i) {
978a2f
+			/* Is the channel number reasonable? */
978a2f
+			if (dec->cdef->data.cdef.ents[i].channo >= dec->numchans) {
978a2f
+				jas_eprintf("error: invalid channel number in CDEF box\n");
978a2f
+				goto error;
978a2f
+			}
978a2f
 			jas_image_setcmpttype(dec->image,
978a2f
 			  dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo],
978a2f
 			  jp2_getct(jas_image_clrspc(dec->image),