Update fork to upstream OpenJPEG v2.5.4#3
Conversation
…ges in non-strict mode (fixes uclouvain#1459)
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.
…p2_decode()/get_tile() (fixes uclouvain#570)
…p2_decode()/get_tile() + add unit test (fixes uclouvain#570)
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.
… destination. fix ht_dec.c:1215 (uclouvain#1492)
…lang suppress warning during build using clang
Require `stdint.h` & `inttypes.h`
…vain#1480) (likely harmless issue as we don't dereference it)
fix ht_dec.c:1215
Integer Overflow at j2k.c:11114
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
…ller that total number of tile-parts Fixes uclouvain#1564
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
…(2.5.2->2.5.3)" This reverts commit 4e3412d.
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.
code documentation updates
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
|
Important Review skippedToo many files! This PR contains 197 files, which is 47 over the limit of 150. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (197)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.