summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMickael Savinaud <savmickael@users.noreply.github.com>2012-11-26 16:13:32 +0000
committerMickael Savinaud <savmickael@users.noreply.github.com>2012-11-26 16:13:32 +0000
commit1ad85ac9eeb7c0b037e5209c6d3f10e80802790b (patch)
tree2d387f3722bcea1a99c67d401c5a71b93b5d4668 /src/lib
parent999a84c77a8b4f36021ccb0193128bf61ee5776c (diff)
[trunk] check if the number of tiles is not incorrect regarding the JPEG2000 norm (thanks Even).
Test associated to this issue should nicely fail. Fixes issue 163
Diffstat (limited to 'src/lib')
-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 */