From: Mickael Savinaud Date: Sun, 17 Mar 2013 18:16:03 +0000 (+0000) Subject: [trunk] correct issue 188 (thanks winfried) and add test about it. Fixes issue 188 X-Git-Tag: version.2.0.1~4^2~285 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e414c8f37e0f392bf1867b614023e9a2ed09d3a;p=openjpeg [trunk] correct issue 188 (thanks winfried) and add test about it. Fixes issue 188 --- diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index 9fd78592..5f2390f3 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -428,12 +428,10 @@ static void opj_jp2_setup_decoding_validation (opj_jp2_t *jp2); static void opj_jp2_setup_header_reading (opj_jp2_t *jp2); /* ----------------------------------------------------------------------- */ - OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box, - OPJ_UINT32 * p_number_bytes_read, - opj_stream_private_t *cio, - opj_event_mgr_t * p_manager - ) + OPJ_UINT32 * p_number_bytes_read, + opj_stream_private_t *cio, + opj_event_mgr_t * p_manager ) { /* read header from file */ OPJ_BYTE l_data_header [8]; @@ -452,6 +450,12 @@ static void opj_jp2_setup_header_reading (opj_jp2_t *jp2); /* process read data */ opj_read_bytes(l_data_header,&(box->length), 4); opj_read_bytes(l_data_header+4,&(box->type), 4); + + if(box->length == 0)/* last box */ + { + box->length = opj_stream_get_number_byte_left(cio); + return OPJ_TRUE; + } /* do we have a "special very large box ?" */ /* read then the XLBox */ @@ -467,14 +471,15 @@ static void opj_jp2_setup_header_reading (opj_jp2_t *jp2); return OPJ_FALSE; } + *p_number_bytes_read = 16; opj_read_bytes(l_data_header,&l_xl_part_size, 4); if (l_xl_part_size != 0) { opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n"); return OPJ_FALSE; } - opj_read_bytes(l_data_header,&(box->length), 4); + opj_read_bytes(l_data_header+4,&(box->length), 4); } - return OPJ_TRUE; + return OPJ_TRUE; } #if 0 diff --git a/tests/nonregression/test_suite.ctest.in b/tests/nonregression/test_suite.ctest.in index 13f66f45..dad81d77 100644 --- a/tests/nonregression/test_suite.ctest.in +++ b/tests/nonregression/test_suite.ctest.in @@ -89,6 +89,8 @@ opj_decompress -i @INPUT_NR_PATH@/mem-b2b86b74-2753.jp2 -o @TEMP_PATH@/mem-b2b8 ! opj_decompress -i @INPUT_NR_PATH@/gdal_fuzzer_check_comp_dx_dy.jp2 -o @TEMP_PATH@/gdal_fuzzer_check_comp_dx_dy.pgx # issue 202 opj_decompress -i @INPUT_NR_PATH@/file409752.jp2 -o @TEMP_PATH@/file409752.png +# issue 188 +opj_decompress -i @INPUT_NR_PATH@/issue188_beach_64bitsbox.jp2 -o @TEMP_PATH@/issue188_beach_64bitsbox.jp2.tif # decode with specific area # prec=12; nb_c=1