From 00f45684a8339e69ed55df2397f3c19d09fecaed Mon Sep 17 00:00:00 2001 From: szukw000 Date: Mon, 31 Jul 2017 13:58:08 +0200 Subject: Catch images broken by AFL --- src/bin/common/color.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/bin/common') diff --git a/src/bin/common/color.c b/src/bin/common/color.c index 8bb96043..598dc8e6 100644 --- a/src/bin/common/color.c +++ b/src/bin/common/color.c @@ -486,6 +486,34 @@ void color_apply_icc_profile(opj_image_t *image) prec = (int)image->comps[0].prec; if (out_space == cmsSigRgbData) { /* enumCS 16 */ + unsigned int i, nr_comp = image->numcomps; + + if (nr_comp > 4) { + nr_comp = 4; + } + for (i = 1; i < nr_comp; ++i) { /* AFL test */ + if (image->comps[0].dx != image->comps[i].dx) { + break; + } + + if (image->comps[0].dy != image->comps[i].dy) { + break; + } + + if (image->comps[0].prec != image->comps[i].prec) { + break; + } + + if (image->comps[0].sgnd != image->comps[i].sgnd) { + break; + } + + } + if (i != nr_comp) { + cmsCloseProfile(in_prof); + return; + } + if (prec <= 8) { in_type = TYPE_RGB_8; out_type = TYPE_RGB_8; -- cgit v1.2.3