From c149db2205efdb7dff507836365bf381af12f8d8 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Fri, 2 Mar 2012 10:38:01 +0000 Subject: [PATCH] [trunk] check the PSot value during the reading of SOT marker --- libopenjpeg/j2k.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 0b0731d4..1fa975d9 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -3627,6 +3627,14 @@ opj_bool j2k_read_sot_v2 ( opj_read_bytes(p_header_data,&l_tot_len,4); /* Psot */ p_header_data+=4; + /* PSot should be equal to zero or >=14 or <= 2^32-1 */ + if ((l_tot_len !=0 ) && (l_tot_len < 14) ) + { + opj_event_msg_v2(p_manager, EVT_ERROR, "Psot value (%d) is not correct regards to the JPEG2000 norm!\n", l_tot_len); + return OPJ_FALSE; + } + + #ifdef USE_JPWL if (l_cp->correct) {