summaryrefslogtreecommitdiff
path: root/third_party/libopenjpeg20/tcd.c
diff options
context:
space:
mode:
authorochang <ochang@chromium.org>2016-07-06 17:02:35 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-06 17:02:35 -0700
commit2f6d1480a1be2b1f82c94219c2d99e67d7e0660d (patch)
tree89bc9abb01000038e6ad2470ebac03638be339e2 /third_party/libopenjpeg20/tcd.c
parent7e6a8484b05819268b4e7f0350cebfb704c6d18c (diff)
downloadpdfium-2f6d1480a1be2b1f82c94219c2d99e67d7e0660d.tar.xz
openjpeg: Prevent integer overflows during calculation of |l_nb_precinct_size|
BUG=625541 Review-Url: https://codereview.chromium.org/2124073003
Diffstat (limited to 'third_party/libopenjpeg20/tcd.c')
-rw-r--r--third_party/libopenjpeg20/tcd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/third_party/libopenjpeg20/tcd.c b/third_party/libopenjpeg20/tcd.c
index aebe9be96c..673633c09b 100644
--- a/third_party/libopenjpeg20/tcd.c
+++ b/third_party/libopenjpeg20/tcd.c
@@ -822,7 +822,14 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
l_res->ph = (l_res->y0 == l_res->y1) ? 0 : (OPJ_UINT32)((l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
/*fprintf(stderr, "\t\t\tres_pw=%d, res_ph=%d\n", l_res->pw, l_res->ph );*/
+ if (l_res->pw && ((OPJ_UINT32)-1) / l_res->pw < l_res->ph) {
+ return OPJ_FALSE;
+ }
l_nb_precincts = l_res->pw * l_res->ph;
+
+ if (((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(opj_tcd_precinct_t) < l_nb_precincts) {
+ return OPJ_FALSE;
+ }
l_nb_precinct_size = l_nb_precincts * (OPJ_UINT32)sizeof(opj_tcd_precinct_t);
if (resno == 0) {
tlcbgxstart = l_tl_prc_x_start;