summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/j2k.c
diff options
context:
space:
mode:
authorMickael Savinaud <savmickael@users.noreply.github.com>2013-02-02 17:12:54 +0000
committerMickael Savinaud <savmickael@users.noreply.github.com>2013-02-02 17:12:54 +0000
commita59a48e7bbe8cc0cfc998c2e59845731a9cfdd35 (patch)
treed77140dd7736c3cbd671a1996fb0fc9f4ad48401 /src/lib/openjp2/j2k.c
parent521754caf526e3a2cc36cefaf82e1c288469665a (diff)
[b2.x.x] backport into 2.x.x the rev 2239 of trunk
Diffstat (limited to 'src/lib/openjp2/j2k.c')
-rw-r--r--src/lib/openjp2/j2k.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index dccab6de..0c0fb102 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -2034,6 +2034,14 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
/* Compute the number of tiles */
l_cp->tw = opj_int_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
l_cp->th = opj_int_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
+
+ /* Check that the number of tiles is valid */
+ if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
+ opj_event_msg( p_manager, EVT_ERROR,
+ "Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
+ l_cp->tw, l_cp->th);
+ return OPJ_FALSE;
+ }
l_nb_tiles = l_cp->tw * l_cp->th;
/* Define the tiles which will be decoded */