diff --git a/Fix-building-on-OpenBSD-big-endian-hosts.patch b/Fix-building-on-OpenBSD-big-endian-hosts.patch new file mode 100644 index 0000000000000000000000000000000000000000..89a07f824538ef77215b6ede4a799dbffbf6b3f9 --- /dev/null +++ b/Fix-building-on-OpenBSD-big-endian-hosts.patch @@ -0,0 +1,37 @@ +From 995d8c96b51f3e510457cf71b5b5902de11dc08c Mon Sep 17 00:00:00 2001 +From: Brad Smith +Date: Sat, 2 Mar 2024 18:09:26 -0500 +Subject: [PATCH] Fix building on OpenBSD big endian hosts + +There is a swap16() function which conflicts with such a macro +in the endian.h header. uint16_t swap16(uint16_t val16); + +Do as suggested and rename the function to opj_swap16(). +--- + src/bin/jp2/convert.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c +index 7205ccf95..234302fe1 100644 +--- a/src/bin/jp2/convert.c ++++ b/src/bin/jp2/convert.c +@@ -664,7 +664,7 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, + + #ifdef OPJ_BIG_ENDIAN + +-static INLINE OPJ_UINT16 swap16(OPJ_UINT16 x) ++static INLINE OPJ_UINT16 opj_swap16(OPJ_UINT16 x) + { + return (OPJ_UINT16)(((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8)); + } +@@ -733,8 +733,8 @@ static int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, + goto fails; + } + #else +- image_w = swap16(image_w); +- image_h = swap16(image_h); ++ image_w = opj_swap16(image_w); ++ image_h = opj_swap16(image_h); + if (fwrite(&image_w, 2, 1, fp) != 1) { + goto fails; + } diff --git a/avoid-use-of-uninitialized-l_current_tile_no-variable.patch b/avoid-use-of-uninitialized-l_current_tile_no-variable.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d53c2d4845385962b9df38a9405a87974021ce6 --- /dev/null +++ b/avoid-use-of-uninitialized-l_current_tile_no-variable.patch @@ -0,0 +1,27 @@ +From 3b0c9b91f50b9578846621616200ca097b7fe761 Mon Sep 17 00:00:00 2001 +From: Even Rouault +Date: Mon, 6 May 2024 19:17:37 +0200 +Subject: [PATCH] opj_j2k_decode_tiles(): avoid use of uninitialized + l_current_tile_no variable + +Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68763 +--- + src/lib/openjp2/j2k.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c +index c0551870b..418078de6 100644 +--- a/src/lib/openjp2/j2k.c ++++ b/src/lib/openjp2/j2k.c +@@ -11698,8 +11698,9 @@ static OPJ_BOOL opj_j2k_decode_tiles(opj_j2k_t *p_j2k, + return OPJ_FALSE; + } + +- if (! opj_j2k_decode_tile(p_j2k, l_current_tile_no, NULL, 0, +- p_stream, p_manager)) { ++ if (!l_go_on || ++ ! opj_j2k_decode_tile(p_j2k, l_current_tile_no, NULL, 0, ++ p_stream, p_manager)) { + opj_event_msg(p_manager, EVT_ERROR, "Failed to decode tile 1/1\n"); + return OPJ_FALSE; + } diff --git a/openjpeg2.spec b/openjpeg2.spec index 6b96b14be86214b53e3b97376d0362e4d971e237..0408c2b8f7ea6f264cfac5996d7b2401838a6cf1 100644 --- a/openjpeg2.spec +++ b/openjpeg2.spec @@ -2,13 +2,15 @@ Name: openjpeg2 Version: 2.5.2 -Release: 1 +Release: 2 Summary: C-Library for JPEG 2000 License: BSD and MIT URL: https://github.com/uclouvain/openjpeg Source0: https://github.com/uclouvain/openjpeg/archive/v%{version}/openjpeg-%{version}.tar.gz Patch0: openjpeg2_opj2.patch +Patch1: Fix-building-on-OpenBSD-big-endian-hosts.patch +Patch2: avoid-use-of-uninitialized-l_current_tile_no-variable.patch BuildRequires: cmake gcc-c++ make zlib-devel libpng-devel libtiff-devel lcms2-devel doxygen java-devel BuildRequires: jbigkit-devel libjpeg-turbo-devel @@ -100,6 +102,10 @@ mv %{buildroot}%{_mandir}/man1/opj_dump.1 %{buildroot}%{_mandir}/man1/opj2_dump. %{_bindir}/opj2_dump %changelog +* Thu Jul 11 2024 zhangxingrong- - 2.5.2-2 +- Merge pull request #1520 from brad0/openbsd_swap16 +- opj_j2k_decode_tiles(): avoid use of uninitialized l_current_tile_no variable + * Tue Mar 26 2024 wangqia - 2.5.2-1 - update 2.5.2