summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMatthieu Darbois <mayeut@users.noreply.github.com>2015-05-19 21:24:44 +0000
committerMatthieu Darbois <mayeut@users.noreply.github.com>2015-05-19 21:24:44 +0000
commit757f9394bf0811ff1355e31d4b7d8565770d0a48 (patch)
treeb0807c96d42ff39b87765bfb1b1313b0922fe47d /src/lib
parentdaed8cc9195555e101ab708a501af2dfe6d5e001 (diff)
[trunk] Add check for number of layers & cblkw/cblkh values (fixes issue 475)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/j2k.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 0be00aa6..8c62a39b 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -2462,6 +2462,11 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k,
}
opj_read_bytes(p_header_data,&l_tcp->numlayers,2); /* SGcod (B) */
p_header_data+=2;
+
+ if ((l_tcp->numlayers < 1U) || (l_tcp->numlayers > 65535U)) {
+ opj_event_msg(p_manager, EVT_ERROR, "Invalid number of layers in COD marker : %d not in range [1-65535]\n", l_tcp->numlayers);
+ return OPJ_FALSE;
+ }
/* If user didn't set a number layer to decode take the max specify in the codestream. */
if (l_cp->m_specific_param.m_dec.m_layer) {
@@ -8631,6 +8636,12 @@ OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k,
++l_current_ptr;
l_tccp->cblkh += 2;
+ if ((l_tccp->cblkw > 10) || (l_tccp->cblkh > 10) || ((l_tccp->cblkw + l_tccp->cblkh) > 12)) {
+ opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element, Invalid cblkw/cblkh combination\n");
+ return OPJ_FALSE;
+ }
+
+
opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1); /* SPcoc (G) */
++l_current_ptr;