Skip to content

Update fork to upstream OpenJPEG v2.5.4#3

Open
sedghi wants to merge 141 commits into
masterfrom
update/upstream-2.5.4
Open

Update fork to upstream OpenJPEG v2.5.4#3
sedghi wants to merge 141 commits into
masterfrom
update/upstream-2.5.4

Conversation

@sedghi

@sedghi sedghi commented Jul 9, 2026

Copy link
Copy Markdown
Member

Advances the cornerstonejs OpenJPEG fork from 2d606701 (~2.5.0-era, Oct 2022) to upstream v2.5.4 (latest stable, 2025-09-20).

No custom patches to carry — the fork's pin is a plain upstream commit with zero divergence (merge-base with upstream == HEAD), and it's a direct ancestor of v2.5.4. Clean version advance.

Validation runs on the codecs submodule-bump PR (wasm build + pixel goldens). Not built locally.

autoantwort and others added 30 commits February 7, 2023 01:08
opj_t2_skip_packet_data(): avoid out-of-bounds reads on truncated images in non-strict mode (fixes uclouvain#1459)
This makes it possible to build j2k.c without warnings using the macOS
13 SDK. Calls to sprintf are replaced with snprintf, passing appropriate
buffer sizes.

It doesn’t appear that any of the changed uses of sprintf were actually
unsafe, so no behavior change is expected aside from SDK compatibility.

The macOS 13 SDK deprecates sprintf as it’s difficult to use safely. The
deprecation warning message is visible when building C++, but it is not
normally visible when building plain C code due to a quirk in how
sprintf is declared in the SDK. However, the deprecation message is
visible when building plain C under Address Sanitizer
(-fsanitize=address). This discrepancy was discovered at
https://crbug.com/1381706 and reported to Apple with a copy at
https://openradar.appspot.com/FB11761475.

The macOS 13 SDK is packaged in Xcode 14.1, released on 2022-11-01. This
also affects the iOS 16 SDK and other 2022-era Apple OS SDKs packaged in
Xcode 14.0, released on 2022-09-12.

j2k.c is visible to the Chromium build via PDFium, and this change is
needed to allow Chromium to move forward to the macOS 13 SDK.

This change is limited to src/lib/openjp2. Other uses of sprintf were
found throughout openjpeg.
openjp2/j2k: replace sprintf calls with snprintf
And fix strict-prototypes/missing-prototypes warnings.
CMake: error out on warnings for strict/missing prototypes.
opj_jp2_read_header(): move setting color_space here instead in opj_jp2_decode()/get_tile() (fixes uclouvain#570)
There are a bunch of loc where we can see a usage of `opj_int_ceildiv`:
```
(OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)a, (OPJ_INT32)b);
```
where a & b are `OPJ_UINT32`.

This can lead to overflow/underflow for some a/b combinations.
Replace those calls by `opj_uint_ceildiv` instead to always get a correct result.

This also allows some valid single tile images with huge tile size to be decoded properly.
Fix uclouvain#1438
fix: use `opj_uint_ceildiv` instead of `opj_int_ceildiv` when necessary
With uclouvain#1450 which goes with 480cc9d "Remove support for non-C99 compilers (like VS2010) that don't support snprintf()",
support for MSVC versions prior to vs2015 is dropped: https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010

This means that all supported MSVC versions do have `stdint.h` & `inttypes.h` now.
For non windows platforms, those headers were already mandatory.

Make them mandatory for all builds.
…lang

suppress warning during build using clang
rouault and others added 28 commits November 13, 2024 17:37
The fix of 2c0823c (uclouvain#1530) broke
decoding of some JPEG2000 files where Isot==0, Psot==0, TPsot==0 and
TNsot==0 like the following ones from the GDAL autotest suite:
autotest/gdrivers/data/jpeg2000/stefan_full_rgba_alpha_1bit.jp2
autotest/gdrivers/data/jpeg2000/3_13bit_and_1bit.jp2
Amend fix of PR 1530 regarding m_sot_length check
…X flag, and make it active when opj_decoder_set_strict_mode() is called with true
Do not turn on 'TPsot==TNsot detection fix' when TNsot==1, and
opj_j2k_add_tlmarker(): validate that current tile-part number if smaller that total number of tile-parts
…onent_1_or_2 + 1 == with_component_0

Fixes uclouvain#1563

Also adjusts sycc420_to_rgb() for potential similar issue (amending
commit 7bd884f)
sycc422_to_rgb(): fix out-of-bounds read accesses when 2 * width_component_1_or_2 + 1 == with_component_0
Consider the case where the caller has not set the p_image
pointer to NULL before calling opj_read_header().

If opj_j2k_read_header_procedure() fails while obtaining the rest
of the marker segment when calling opj_stream_read_data() because
the data stream is too short, then opj_j2k_read_header() will
never have the chance to initialize p_image, leaving it
uninitialized.

opj_jp2_read_header() will check the p_image value whether
opj_j2k_read_header() suceeded or failed. This may be detected as
an error in valgrind or ASAN.

The fix is to check whether opj_j2k_read_header() suceeded before
using the output argument p_image.
opj_jp2_read_header: Check for error after parsing header.
Generate pkg-config Libs.private from the actual dependencies linked into
our libraries, rather than hardcoding static lists, to avoid overlinking
of library users when pkg-config is invoked with --static.  libopenjpip
doesn't actually link with libcurl, libfcgi, or libpthread, and neither
of our libraries links with libm on Windows (which doesn't have libm).
pkgconfig: drop unused libraries from `Libs.private`
Fix CMake warning: Compatibility with CMake < 3.10 will be removed
Bump cmake_minimum_required() in thirdparty/ and tools/ctest_scripts/travis-ci.cmake
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 197 files, which is 47 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

Upgrade to a paid plan to raise the limit.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ec7521c-09e2-405d-a57d-42a06e8edf04

📥 Commits

Reviewing files that changed from the base of the PR and between 2d60670 and 6c4a29b.

📒 Files selected for processing (197)
  • .github/workflows/abi_check.yml
  • .github/workflows/build.yml
  • .github/workflows/cifuzz.yml
  • .github/workflows/code_style.yml
  • CHANGELOG.md
  • CMakeLists.txt
  • HOWTO-RELEASE
  • INSTALL.md
  • NEWS.md
  • appveyor.yml
  • doc/man/man3/libopenjp2.3
  • src/bin/common/color.c
  • src/bin/common/opj_apps_config.h.cmake.in
  • src/bin/jp2/CMakeLists.txt
  • src/bin/jp2/convert.c
  • src/bin/jp2/convertbmp.c
  • src/bin/jp2/converttif.c
  • src/bin/jp2/index.c
  • src/bin/jp2/opj_compress.c
  • src/bin/jp2/opj_decompress.c
  • src/bin/wx/OPJViewer/source/imagjpeg2000.cpp
  • src/bin/wx/OPJViewer/source/wxj2kparser.cpp
  • src/lib/openjp2/CMakeLists.txt
  • src/lib/openjp2/bench_dwt.c
  • src/lib/openjp2/dwt.c
  • src/lib/openjp2/ht_dec.c
  • src/lib/openjp2/j2k.c
  • src/lib/openjp2/j2k.h
  • src/lib/openjp2/jp2.c
  • src/lib/openjp2/libopenjp2.pc.cmake.in
  • src/lib/openjp2/openjpeg.c
  • src/lib/openjp2/openjpeg.h
  • src/lib/openjp2/opj_common.h
  • src/lib/openjp2/opj_config.h.cmake.in
  • src/lib/openjp2/opj_config_private.h.cmake.in
  • src/lib/openjp2/opj_includes.h
  • src/lib/openjp2/opj_inttypes.h
  • src/lib/openjp2/opj_stdint.h
  • src/lib/openjp2/t1.c
  • src/lib/openjp2/t1_ht_generate_luts.c
  • src/lib/openjp2/t2.c
  • src/lib/openjp2/tcd.c
  • src/lib/openjp2/tcd.h
  • src/lib/openjp2/thread.c
  • src/lib/openjpip/CMakeLists.txt
  • src/lib/openjpip/auxtrans_manager.h
  • src/lib/openjpip/box_manager.c
  • src/lib/openjpip/box_manager.h
  • src/lib/openjpip/boxheader_manager.c
  • src/lib/openjpip/boxheader_manager.h
  • src/lib/openjpip/byte_manager.h
  • src/lib/openjpip/cachemodel_manager.c
  • src/lib/openjpip/codestream_manager.c
  • src/lib/openjpip/dec_clientmsg_handler.c
  • src/lib/openjpip/faixbox_manager.c
  • src/lib/openjpip/index_manager.c
  • src/lib/openjpip/jp2k_encoder.c
  • src/lib/openjpip/libopenjpip.pc.cmake.in
  • src/lib/openjpip/metadata_manager.c
  • src/lib/openjpip/mhixbox_manager.c
  • src/lib/openjpip/msgqueue_manager.c
  • src/lib/openjpip/msgqueue_manager.h
  • src/lib/openjpip/openjpip.h
  • src/lib/openjpip/placeholder_manager.c
  • src/lib/openjpip/query_parser.c
  • src/lib/openjpip/session_manager.h
  • src/lib/openjpip/sock_manager.h
  • tests/compare_images.c
  • tests/conformance/CMakeLists.txt
  • tests/nonregression/CMakeLists.txt
  • tests/nonregression/md5refs.txt
  • tests/nonregression/test_suite.ctest.in
  • tests/pdf2jp2.c
  • tests/unit/CMakeLists.txt
  • tests/unit/testjp2.c
  • thirdparty/include/zconf.h
  • thirdparty/include/zlib.h
  • thirdparty/libpng/CMakeLists.txt
  • thirdparty/libpng/LICENSE
  • thirdparty/libpng/png.c
  • thirdparty/libpng/png.h
  • thirdparty/libpng/pngconf.h
  • thirdparty/libpng/pngdebug.h
  • thirdparty/libpng/pngerror.c
  • thirdparty/libpng/pngget.c
  • thirdparty/libpng/pnginfo.h
  • thirdparty/libpng/pnglibconf.h
  • thirdparty/libpng/pngmem.c
  • thirdparty/libpng/pngpread.c
  • thirdparty/libpng/pngpriv.h
  • thirdparty/libpng/pngread.c
  • thirdparty/libpng/pngrio.c
  • thirdparty/libpng/pngrtran.c
  • thirdparty/libpng/pngrutil.c
  • thirdparty/libpng/pngset.c
  • thirdparty/libpng/pngstruct.h
  • thirdparty/libpng/pngtrans.c
  • thirdparty/libpng/pngwio.c
  • thirdparty/libpng/pngwrite.c
  • thirdparty/libpng/pngwtran.c
  • thirdparty/libpng/pngwutil.c
  • thirdparty/libtiff/CMakeLists.txt
  • thirdparty/libtiff/LibraryFeatures.cmake
  • thirdparty/libtiff/TypeSizeChecks.cmake
  • thirdparty/libtiff/snprintf.c
  • thirdparty/libtiff/t4.h
  • thirdparty/libtiff/test_inline.c
  • thirdparty/libtiff/tif_aux.c
  • thirdparty/libtiff/tif_close.c
  • thirdparty/libtiff/tif_codec.c
  • thirdparty/libtiff/tif_color.c
  • thirdparty/libtiff/tif_compress.c
  • thirdparty/libtiff/tif_config.h.cmake.in
  • thirdparty/libtiff/tif_config.h.in
  • thirdparty/libtiff/tif_dir.c
  • thirdparty/libtiff/tif_dir.h
  • thirdparty/libtiff/tif_dirinfo.c
  • thirdparty/libtiff/tif_dirread.c
  • thirdparty/libtiff/tif_dirwrite.c
  • thirdparty/libtiff/tif_dumpmode.c
  • thirdparty/libtiff/tif_error.c
  • thirdparty/libtiff/tif_extension.c
  • thirdparty/libtiff/tif_fax3.c
  • thirdparty/libtiff/tif_fax3.h
  • thirdparty/libtiff/tif_fax3sm.c
  • thirdparty/libtiff/tif_flush.c
  • thirdparty/libtiff/tif_getimage.c
  • thirdparty/libtiff/tif_hash_set.c
  • thirdparty/libtiff/tif_hash_set.h
  • thirdparty/libtiff/tif_jbig.c
  • thirdparty/libtiff/tif_jpeg.c
  • thirdparty/libtiff/tif_jpeg_12.c
  • thirdparty/libtiff/tif_luv.c
  • thirdparty/libtiff/tif_lzma.c
  • thirdparty/libtiff/tif_lzw.c
  • thirdparty/libtiff/tif_next.c
  • thirdparty/libtiff/tif_ojpeg.c
  • thirdparty/libtiff/tif_open.c
  • thirdparty/libtiff/tif_packbits.c
  • thirdparty/libtiff/tif_pixarlog.c
  • thirdparty/libtiff/tif_predict.c
  • thirdparty/libtiff/tif_predict.h
  • thirdparty/libtiff/tif_print.c
  • thirdparty/libtiff/tif_read.c
  • thirdparty/libtiff/tif_stream.cxx
  • thirdparty/libtiff/tif_strip.c
  • thirdparty/libtiff/tif_swab.c
  • thirdparty/libtiff/tif_thunder.c
  • thirdparty/libtiff/tif_tile.c
  • thirdparty/libtiff/tif_unix.c
  • thirdparty/libtiff/tif_version.c
  • thirdparty/libtiff/tif_warning.c
  • thirdparty/libtiff/tif_win32.c
  • thirdparty/libtiff/tif_write.c
  • thirdparty/libtiff/tif_zip.c
  • thirdparty/libtiff/tiff.h
  • thirdparty/libtiff/tiffconf.h.cmake.in
  • thirdparty/libtiff/tiffconf.h.in
  • thirdparty/libtiff/tiffio.h
  • thirdparty/libtiff/tiffiop.h
  • thirdparty/libtiff/uvcode.h
  • thirdparty/libz/CMakeLists.txt
  • thirdparty/libz/adler32.c
  • thirdparty/libz/compress.c
  • thirdparty/libz/crc32.c
  • thirdparty/libz/crc32.h
  • thirdparty/libz/deflate.c
  • thirdparty/libz/deflate.h
  • thirdparty/libz/gzclose.c
  • thirdparty/libz/gzguts.h
  • thirdparty/libz/gzlib.c
  • thirdparty/libz/gzread.c
  • thirdparty/libz/gzwrite.c
  • thirdparty/libz/infback.c
  • thirdparty/libz/inffast.c
  • thirdparty/libz/inffast.h
  • thirdparty/libz/inflate.c
  • thirdparty/libz/inflate.h
  • thirdparty/libz/inftrees.c
  • thirdparty/libz/inftrees.h
  • thirdparty/libz/trees.c
  • thirdparty/libz/uncompr.c
  • thirdparty/libz/zlib.h
  • thirdparty/libz/zutil.c
  • thirdparty/libz/zutil.h
  • tools/ctest_scripts/travis-ci.cmake
  • tools/travis-ci/abi-check.sh
  • tools/travis-ci/install.sh
  • tools/travis-ci/knownfailures-Ubuntu22.04-gcc11.4.0-x86_64-Release-3rdP.txt
  • tools/travis-ci/knownfailures-macOS14.7-xcode15.4-arm64-Release-3rdP.txt
  • tools/travis-ci/run.sh
  • wrapping/java/openjp2/JavaOpenJPEG.c
  • wrapping/java/openjp2/JavaOpenJPEGDecoder.c
  • wrapping/java/openjp2/java-sources/org/openJpeg/OpenJPEGJavaDecoder.java
  • wrapping/java/openjp2/java-sources/org/openJpeg/OpenJPEGJavaEncoder.java
  • wrapping/java/openjp2/org_openJpeg_OpenJPEGJavaDecoder.h
  • wrapping/java/openjp2/org_openJpeg_OpenJPEGJavaEncoder.h

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update/upstream-2.5.4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.