openjpeg2/0018-tcd_get_decoded_tile_size.patch
Ismail Dönmez 22f0cbcc82 Accepting request 446992 from home:michel_mno:branches:graphics
- update to version 2.1.2
  Bug fixes including security fixes among which:
  CVE-2016-8332 CVE-2016-7163
  CVE-2016-5139 CVE-2016-5159
  CVE-2016-5158 (not listed but solved different way)
  Huge amount of critical bugfixes
  Speed improvements
  No API/ABI break compared to v2.1.1/v2.1
- some doc files now have '.md' suffix (like README.md)
- CVE-2016-5152 with new 0018-tcd_get_decoded_tile_size.patch

This openjpeg2 is solution to avoid ppc64 build error
of graphics/ ImageMagick for TW.
But this openjpeg2 version do not build on openSUSE 13.1
because cmake 2.8 do not support "target_compile_options"
Do we still have to build for openSUSE 13.1 ?

OBS-URL: https://build.opensuse.org/request/show/446992
OBS-URL: https://build.opensuse.org/package/show/graphics/openjpeg2?expand=0&rev=25
2016-12-19 09:58:53 +00:00

62 lines
2.5 KiB
Diff

---
src/lib/openjp2/j2k.c | 4 ++++
src/lib/openjp2/tcd.c | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
Index: openjpeg-2.1.2/src/lib/openjp2/j2k.c
===================================================================
--- openjpeg-2.1.2.orig/src/lib/openjp2/j2k.c
+++ openjpeg-2.1.2/src/lib/openjp2/j2k.c
@@ -8097,6 +8097,10 @@ OPJ_BOOL opj_j2k_read_tile_header(
*p_tile_index = p_j2k->m_current_tile_number;
*p_go_on = OPJ_TRUE;
*p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd);
+ if (*p_data_size == (OPJ_UINT32)-1) {
+ return OPJ_FALSE;
+ }
+
*p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0;
*p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0;
*p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1;
Index: openjpeg-2.1.2/src/lib/openjp2/tcd.c
===================================================================
--- openjpeg-2.1.2.orig/src/lib/openjp2/tcd.c
+++ openjpeg-2.1.2/src/lib/openjp2/tcd.c
@@ -1154,6 +1154,7 @@ OPJ_UINT32 opj_tcd_get_decoded_tile_size
opj_tcd_tilecomp_t * l_tile_comp = 00;
opj_tcd_resolution_t * l_res = 00;
OPJ_UINT32 l_size_comp, l_remaining;
+ OPJ_UINT32 l_temp;
l_tile_comp = p_tcd->tcd_image->tiles->comps;
l_img_comp = p_tcd->image->comps;
@@ -1171,7 +1172,18 @@ OPJ_UINT32 opj_tcd_get_decoded_tile_size
}
l_res = l_tile_comp->resolutions + l_tile_comp->minimum_num_resolutions - 1;
- l_data_size += l_size_comp * (OPJ_UINT32)((l_res->x1 - l_res->x0) * (l_res->y1 - l_res->y0));
+ l_temp = (OPJ_UINT32)((l_res->x1 - l_res->x0) * (l_res->y1 - l_res->y0)); /* x1*y1 can't overflow */
+
+ if (l_size_comp && ((OPJ_UINT32)-1) / l_size_comp < l_temp) {
+ return (OPJ_UINT32)-1;
+ }
+ l_temp *= l_size_comp;
+
+ if (l_temp > ((OPJ_UINT32)-1) - l_data_size) {
+ return (OPJ_UINT32)-1;
+ }
+ l_data_size += l_temp;
+
++l_img_comp;
++l_tile_comp;
}
@@ -1366,7 +1378,7 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_
OPJ_UINT32 l_stride, l_width,l_height;
l_data_size = opj_tcd_get_decoded_tile_size(p_tcd);
- if (l_data_size > p_dest_length) {
+ if (l_data_size == (OPJ_UINT32)-1 || l_data_size > p_dest_length) {
return OPJ_FALSE;
}