From e166e4a209d9a3e4b583e4b2cdcbab2c57967eb1 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 28 Apr 2016 19:20:14 +0200 Subject: [PATCH] Check SSIZ is valid in opj_j2k_read_siz (#762) --- src/lib/openjp2/j2k.c | 8 +++++++- tests/nonregression/CMakeLists.txt | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 525f629a..f6be14de 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -2154,10 +2154,16 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k, if( l_img_comp->dx < 1 || l_img_comp->dx > 255 || l_img_comp->dy < 1 || l_img_comp->dy > 255 ) { opj_event_msg(p_manager, EVT_ERROR, - "Invalid values for comp = %d : dx=%u dy=%u\n (should be between 1 and 255 according the JPEG2000 norm)", + "Invalid values for comp = %d : dx=%u dy=%u (should be between 1 and 255 according to the JPEG2000 norm)\n", i, l_img_comp->dx, l_img_comp->dy); return OPJ_FALSE; } + if( l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */ + opj_event_msg(p_manager, EVT_ERROR, + "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n", + i, l_img_comp->prec); + return OPJ_FALSE; + } #ifdef USE_JPWL if (l_cp->correct) { diff --git a/tests/nonregression/CMakeLists.txt b/tests/nonregression/CMakeLists.txt index ce95af87..40283169 100644 --- a/tests/nonregression/CMakeLists.txt +++ b/tests/nonregression/CMakeLists.txt @@ -37,7 +37,7 @@ set(BLACKLIST_JPEG2000_TMP #edf_c2_20.jp2 #looks ok as per kdu_jp2info edf_c2_1377017.jp2 edf_c2_1002767.jp2 - #edf_c2_10025.jp2 + edf_c2_10025.jp2 edf_c2_1000234.jp2 edf_c2_225881.jp2 edf_c2_1000671.jp2 @@ -46,6 +46,7 @@ set(BLACKLIST_JPEG2000_TMP edf_c2_101463.jp2 edf_c2_1674177.jp2 edf_c2_1673169.jp2 + issue418.jp2 issue429.jp2 issue427-null-image-size.jp2 issue427-illegal-tile-offset.jp2