|
|
83be9e |
Backport of the upstream commits:
|
|
|
83be9e |
|
|
|
83be9e |
From d91198abd00fc435a397fe6bad906a4c1748e9cf Mon Sep 17 00:00:00 2001
|
|
|
83be9e |
From: Michael Adams <mdadams@ece.uvic.ca>
|
|
|
83be9e |
Date: Sun, 23 Oct 2016 03:34:35 -0700
|
|
|
83be9e |
Subject: [PATCH] Fixed another integer overflow problem.
|
|
|
83be9e |
|
|
|
83be9e |
From a712a2041085e7cd5f2b153e1532ac2a2954ffaa Mon Sep 17 00:00:00 2001
|
|
|
83be9e |
From: Michael Adams <mdadams@ece.uvic.ca>
|
|
|
83be9e |
Date: Thu, 2 Mar 2017 09:28:42 -0800
|
|
|
83be9e |
Subject: [PATCH] Added some additional checking to prevent a potential integer
|
|
|
83be9e |
overflow due to conversion in the JPC decoder.
|
|
|
83be9e |
|
|
|
83be9e |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c jasper-1.900.1/src/libjasper/jpc/jpc_dec.c
|
|
|
83be9e |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c 2017-03-31 22:12:06.000000000 +0200
|
|
|
83be9e |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_dec.c 2017-03-31 22:14:46.112781219 +0200
|
|
|
83be9e |
@@ -1174,6 +1174,7 @@ static int jpc_dec_process_siz(jpc_dec_t
|
|
|
83be9e |
int htileno;
|
|
|
83be9e |
int vtileno;
|
|
|
83be9e |
jpc_dec_cmpt_t *cmpt;
|
|
|
83be9e |
+ size_t size;
|
|
|
83be9e |
|
|
|
83be9e |
dec->xstart = siz->xoff;
|
|
|
83be9e |
dec->ystart = siz->yoff;
|
|
|
83be9e |
@@ -1210,7 +1211,11 @@ static int jpc_dec_process_siz(jpc_dec_t
|
|
|
83be9e |
|
|
|
83be9e |
dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
|
|
|
83be9e |
dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
|
|
|
83be9e |
- dec->numtiles = dec->numhtiles * dec->numvtiles;
|
|
|
83be9e |
+ if (!jas_safe_size_mul(dec->numhtiles, dec->numvtiles, &size) ||
|
|
|
83be9e |
+ size > INT_MAX) {
|
|
|
83be9e |
+ return -1;
|
|
|
83be9e |
+ }
|
|
|
83be9e |
+ dec->numtiles = size;
|
|
|
83be9e |
if (!(dec->tiles = jas_calloc(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
|
|
|
83be9e |
return -1;
|
|
|
83be9e |
}
|