]> granicus.if.org Git - openjpeg/commitdiff
[trunk] add a check on precinct size (fixes issue 420)
authorAntonin Descampe <antonin@gmail.com>
Thu, 30 Oct 2014 18:00:45 +0000 (18:00 +0000)
committerAntonin Descampe <antonin@gmail.com>
Thu, 30 Oct 2014 18:00:45 +0000 (18:00 +0000)
src/lib/openjp2/j2k.c

index f30b3a369b0543ca18bb54d42e9b189e369b6184..46f50eeb8a9406f17de14240381f479a91abc9bd 100644 (file)
@@ -8617,6 +8617,11 @@ OPJ_BOOL opj_j2k_read_SPCod_SPCoc(  opj_j2k_t *p_j2k,
                 for     (i = 0; i < l_tccp->numresolutions; ++i) {
                         opj_read_bytes(l_current_ptr,&l_tmp ,1);                /* SPcoc (I_i) */
                         ++l_current_ptr;
+                        /* Precinct exponent 0 is only allowed for lowest resolution level (Table A.21) */
+                        if ((i != 0) && (((l_tmp & 0xf) == 0) || ((l_tmp >> 4) == 0))) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct size\n");
+                                return OPJ_FALSE;
+                        }
                         l_tccp->prcw[i] = l_tmp & 0xf;
                         l_tccp->prch[i] = l_tmp >> 4;
                 }