summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-07-26 23:25:38 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-07-27 18:10:03 +0200
commitd6fa30099797c68c6a67decf58571dd59dbf734b (patch)
treeb57ff50d3508ba9f49de17af98017005a6fd7341 /src/lib
parenta88cbb6a0b3539461dfb29922102953b7a7fc3a7 (diff)
Avoids undefined shift behaviour in m_dc_level_shift computation
Fixes warning found on clusterfuzz-testcase-minimized-5146316340461568 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2495 Credit to OSS Fuzz
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/j2k.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 6b86ddfe..8bd77f43 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -2231,9 +2231,12 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
i, l_img_comp->dx, l_img_comp->dy);
return OPJ_FALSE;
}
- if (l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */
+ /* Avoids later undefined shift in computation of */
+ /* p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1
+ << (l_image->comps[i].prec - 1); */
+ if (l_img_comp->prec > 32) {
opj_event_msg(p_manager, EVT_ERROR,
- "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n",
+ "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 32)\n",
i, l_img_comp->prec);
return OPJ_FALSE;
}
@@ -6267,6 +6270,13 @@ static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
++p_header_data;
l_comp->sgnd = (l_comp_def >> 7) & 1;
l_comp->prec = (l_comp_def & 0x7f) + 1;
+
+ if (l_comp->prec > 32) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 32)\n",
+ i, l_comp->prec);
+ return OPJ_FALSE;
+ }
++l_comp;
}