public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/openjpeg] f45: Apply proposed fix for CVE-2026-107080
@ 2026-10-28 22:15 Sandro Mani
  0 siblings, 0 replies; only message in thread
From: Sandro Mani @ 2026-10-28 22:15 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/openjpeg
Branch : f45
Commit : d356e889ec350478f3ddefbb175cc8a2388ed98f
Author : Sandro Mani <manisandro@gmail.com>
Date   : 2026-10-28T23:14:24+01:00
Stats  : +329/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/openjpeg/c/d356e889ec350478f3ddefbb175cc8a2388ed98f?branch=f45

Log:
Apply proposed fix for CVE-2026-107080

---
diff --git a/1674.patch b/1674.patch
new file mode 100644
index 0000000..6b693d9
--- /dev/null
+++ b/1674.patch
@@ -0,0 +1,323 @@
+diff -rupN --no-dereference openjpeg-2.5.4/src/lib/openjp2/dwt.c openjpeg-2.5.4-new/src/lib/openjp2/dwt.c
+--- openjpeg-2.5.4/src/lib/openjp2/dwt.c	2025-09-20 19:46:23.000000000 +0200
++++ openjpeg-2.5.4-new/src/lib/openjp2/dwt.c	2026-10-28 23:14:09.915571679 +0100
+@@ -1560,6 +1560,10 @@ static void opj_dwt_encode_and_deinterle
+     const OPJ_UINT32 sn = (height + (even ? 1 : 0)) >> 1;
+     const OPJ_UINT32 dn = height - sn;
+ 
++    if (height == 0) {
++        return;
++    }
++
+     opj_dwt_fetch_cols_vertical_pass(arrayIn, tmpIn, height, stride_width, cols);
+ 
+ #define OPJ_Sc(i) tmp[(i)*2* NB_ELTS_V8 + c]
+diff -rupN --no-dereference openjpeg-2.5.4/tests/CMakeLists.txt openjpeg-2.5.4-new/tests/CMakeLists.txt
+--- openjpeg-2.5.4/tests/CMakeLists.txt	2025-09-20 19:46:23.000000000 +0200
++++ openjpeg-2.5.4-new/tests/CMakeLists.txt	2026-10-28 23:14:09.915965674 +0100
+@@ -40,6 +40,9 @@ add_executable(compare_dump_files ${comp
+ add_executable(j2k_random_tile_access j2k_random_tile_access.c)
+ target_link_libraries(j2k_random_tile_access ${OPENJPEG_LIBRARY_NAME})
+ 
++add_executable(test_empty_resolution_encode test_empty_resolution_encode.c)
++target_link_libraries(test_empty_resolution_encode ${OPENJPEG_LIBRARY_NAME})
++
+ add_executable(compare_raw_files ${compare_raw_files_SRCS})
+ 
+ add_executable(test_tile_encoder test_tile_encoder.c)
+@@ -83,6 +86,10 @@ set_property(TEST rta4 APPEND PROPERTY D
+ add_test(NAME rta5 COMMAND j2k_random_tile_access tte5.j2k)
+ set_property(TEST rta5 APPEND PROPERTY DEPENDS tte5)
+ 
++# Non-regression test for encoding tiles whose lower resolution levels have no
++# rows (self-contained, no test data).
++add_test(NAME empty_resolution_encode COMMAND test_empty_resolution_encode)
++
+ add_test(NAME tda_prep_reversible_no_precinct COMMAND test_tile_encoder 1 256 256 32 32 8 0 reversible_no_precinct.j2k 4 4 3 0 0 1)
+ add_test(NAME tda_reversible_no_precinct COMMAND test_decode_area -q reversible_no_precinct.j2k)
+ set_property(TEST tda_reversible_no_precinct APPEND PROPERTY DEPENDS tda_prep_reversible_no_precinct)
+diff -rupN --no-dereference openjpeg-2.5.4/tests/test_empty_resolution_encode.c openjpeg-2.5.4-new/tests/test_empty_resolution_encode.c
+--- openjpeg-2.5.4/tests/test_empty_resolution_encode.c	1970-01-01 01:00:00.000000000 +0100
++++ openjpeg-2.5.4-new/tests/test_empty_resolution_encode.c	2026-10-28 23:14:09.916108523 +0100
+@@ -0,0 +1,281 @@
++/*
++ * Copyright (c) 2026, OpenJPEG contributors
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
++ * POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * Non-regression test for encoding tiles whose lower resolution levels have
++ * no rows.
++ *
++ * When a tile is short and the number of decomposition levels is large,
++ * opj_int_ceildivpow2() can map a tile's two edges onto the same coordinate,
++ * so a resolution level ends up with a zero height.
++ * opj_dwt_encode_procedure() still runs the forward 5/3 vertical pass over
++ * such a level, once per group of columns, with height 0.
++ *
++ * At an even start that did nothing. At an odd start
++ * opj_dwt_encode_and_deinterleave_v() read and assigned tmp[8..15] for two
++ * rows that do not exist, which runs past the end of the scratch buffer when
++ * the tile's largest resolution level is a single sample.
++ *
++ * The geometries below are encoded losslessly, decoded again, and compared
++ * sample by sample: a reversible encode must return exactly what it was
++ * given. Several of them are encoded in one process, which is what makes the
++ * damage visible: the overrun lands in the scratch buffer, not in the
++ * codestream, so a single encode round-trips exactly.
++ *
++ * The test needs no external data.
++ */
++
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++
++#include "openjpeg.h"
++
++static void quiet_callback(const char *msg, void *client_data)
++{
++    (void)msg;
++    (void)client_data;
++}
++
++typedef struct {
++    const char *name;
++    OPJ_UINT32 w;
++    OPJ_UINT32 h;
++    OPJ_UINT32 tdx;
++    OPJ_UINT32 tdy;
++    int numres;
++} geometry_t;
++
++/* cp_tdx and cp_tdy must be at least 2^(numres-1); see opj_j2k_encoding_validation(). */
++static const geometry_t geometries[] = {
++    /* An edge tile whose lower resolution levels have height 0 at an odd start. */
++    { "col_1x6_t4x5_n3",       1,  6,   4,  5, 3 },
++    { "col_33x37_t32x36_n5",  33, 37,  32, 36, 5 },
++    /* Controls: an edge tile in each axis with no empty resolution level. */
++    { "ctl_8x8_t4x4_n3",       8,  8,   4,  4, 3 },
++    { "ctl_17x16_t16x16_n5",  17, 16,  16, 16, 5 }
++};
++
++static opj_image_t *create_image(OPJ_UINT32 w, OPJ_UINT32 h)
++{
++    opj_image_cmptparm_t cmptparm;
++    opj_image_t *image;
++    OPJ_UINT32 x, y;
++
++    memset(&cmptparm, 0, sizeof(cmptparm));
++    cmptparm.dx = 1;
++    cmptparm.dy = 1;
++    cmptparm.w = w;
++    cmptparm.h = h;
++    cmptparm.x0 = 0;
++    cmptparm.y0 = 0;
++    cmptparm.prec = 8;
++    cmptparm.sgnd = 0;
++
++    image = opj_image_create(1, &cmptparm, OPJ_CLRSPC_GRAY);
++    if (!image) {
++        return NULL;
++    }
++    image->x0 = 0;
++    image->y0 = 0;
++    image->x1 = w;
++    image->y1 = h;
++
++    for (y = 0; y < h; ++y) {
++        for (x = 0; x < w; ++x) {
++            image->comps[0].data[y * w + x] = (OPJ_INT32)((x * 7 + y * 13) & 0xff);
++        }
++    }
++    return image;
++}
++
++/* Encode losslessly to tmpfile. Returns OPJ_TRUE on success. */
++static OPJ_BOOL encode(const geometry_t *g, const char *tmpfile)
++{
++    opj_cparameters_t parameters;
++    opj_image_t *image;
++    opj_codec_t *codec;
++    opj_stream_t *stream;
++    OPJ_BOOL ok;
++
++    image = create_image(g->w, g->h);
++    if (!image) {
++        return OPJ_FALSE;
++    }
++
++    opj_set_default_encoder_parameters(&parameters);
++    parameters.tcp_numlayers = 1;
++    parameters.cp_disto_alloc = 1;
++    parameters.numresolution = g->numres;
++    parameters.tile_size_on = OPJ_TRUE;
++    parameters.cp_tx0 = 0;
++    parameters.cp_ty0 = 0;
++    parameters.cp_tdx = (int)g->tdx;
++    parameters.cp_tdy = (int)g->tdy;
++    parameters.irreversible = 0; /* reversible 5/3: the encode must round-trip */
++
++    codec = opj_create_compress(OPJ_CODEC_J2K);
++    if (!codec) {
++        opj_image_destroy(image);
++        return OPJ_FALSE;
++    }
++    opj_set_info_handler(codec, quiet_callback, NULL);
++    opj_set_warning_handler(codec, quiet_callback, NULL);
++    opj_set_error_handler(codec, quiet_callback, NULL);
++
++    if (!opj_setup_encoder(codec, &parameters, image)) {
++        opj_destroy_codec(codec);
++        opj_image_destroy(image);
++        return OPJ_FALSE;
++    }
++
++    stream = opj_stream_create_default_file_stream(tmpfile, OPJ_FALSE);
++    if (!stream) {
++        opj_destroy_codec(codec);
++        opj_image_destroy(image);
++        return OPJ_FALSE;
++    }
++
++    ok = opj_start_compress(codec, image, stream) &&
++         opj_encode(codec, stream) &&
++         opj_end_compress(codec, stream);
++
++    opj_stream_destroy(stream);
++    opj_destroy_codec(codec);
++    opj_image_destroy(image);
++    return ok;
++}
++
++static opj_image_t *decode(const char *tmpfile)
++{
++    opj_dparameters_t parameters;
++    opj_codec_t *codec;
++    opj_stream_t *stream;
++    opj_image_t *image = NULL;
++
++    stream = opj_stream_create_default_file_stream(tmpfile, OPJ_TRUE);
++    if (!stream) {
++        return NULL;
++    }
++
++    codec = opj_create_decompress(OPJ_CODEC_J2K);
++    if (!codec) {
++        opj_stream_destroy(stream);
++        return NULL;
++    }
++    opj_set_info_handler(codec, quiet_callback, NULL);
++    opj_set_warning_handler(codec, quiet_callback, NULL);
++    opj_set_error_handler(codec, quiet_callback, NULL);
++
++    opj_set_default_decoder_parameters(&parameters);
++    if (!opj_setup_decoder(codec, &parameters) ||
++            !opj_read_header(stream, codec, &image) ||
++            !opj_decode(codec, stream, image) ||
++            !opj_end_decompress(codec, stream)) {
++        if (image) {
++            opj_image_destroy(image);
++            image = NULL;
++        }
++    }
++
++    opj_destroy_codec(codec);
++    opj_stream_destroy(stream);
++    return image;
++}
++
++/* Returns 0 if the geometry round-trips exactly, 1 otherwise. */
++static int check(const geometry_t *g)
++{
++    char tmpfile[128];
++    opj_image_t *decoded;
++    OPJ_UINT32 x, y;
++    OPJ_UINT32 wrong = 0;
++
++    sprintf(tmpfile, "test_empty_resolution_%s.j2k", g->name);
++
++    if (!encode(g, tmpfile)) {
++        fprintf(stderr, "ERROR: %s: failed to encode\n", g->name);
++        remove(tmpfile);
++        return 1;
++    }
++
++    decoded = decode(tmpfile);
++    remove(tmpfile);
++    if (!decoded) {
++        fprintf(stderr, "ERROR: %s: failed to decode\n", g->name);
++        return 1;
++    }
++
++    if (decoded->comps[0].w != g->w || decoded->comps[0].h != g->h) {
++        fprintf(stderr, "ERROR: %s: decoded %ux%u, expected %ux%u\n",
++                g->name, decoded->comps[0].w, decoded->comps[0].h, g->w, g->h);
++        opj_image_destroy(decoded);
++        return 1;
++    }
++
++    for (y = 0; y < g->h; ++y) {
++        for (x = 0; x < g->w; ++x) {
++            const OPJ_INT32 expected = (OPJ_INT32)((x * 7 + y * 13) & 0xff);
++            const OPJ_INT32 got = decoded->comps[0].data[y * g->w + x];
++            if (got != expected) {
++                if (wrong < 4) {
++                    fprintf(stderr,
++                            "ERROR: %s: sample (%u, %u) is %d, expected %d\n",
++                            g->name, x, y, got, expected);
++                }
++                ++wrong;
++            }
++        }
++    }
++
++    opj_image_destroy(decoded);
++
++    if (wrong) {
++        fprintf(stderr,
++                "ERROR: %s: a reversible encode did not round-trip "
++                "(%u of %u samples differ)\n",
++                g->name, wrong, g->w * g->h);
++        return 1;
++    }
++    return 0;
++}
++
++int main(void)
++{
++    const size_t n = sizeof(geometries) / sizeof(geometries[0]);
++    size_t i;
++    int failed = 0;
++
++    for (i = 0; i < n; ++i) {
++        failed += check(&geometries[i]);
++    }
++
++    if (failed) {
++        fprintf(stderr, "%d of %u geometries failed\n", failed, (OPJ_UINT32)n);
++        return EXIT_FAILURE;
++    }
++    return EXIT_SUCCESS;
++}

diff --git a/openjpeg.spec b/openjpeg.spec
index ba7a594..73c61b6 100644
--- a/openjpeg.spec
+++ b/openjpeg.spec
@@ -14,7 +14,7 @@
 
 Name:           openjpeg
 Version:        2.5.4
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        C-Library for JPEG 2000
 
 # windirent.h is MIT, the rest is BSD
@@ -25,6 +25,8 @@ Source0:        https://github.com/uclouvain/openjpeg/archive/v%{version}/%{name
 # git clone git@github.com:uclouvain/openjpeg-data.git
 Source1:        data.tar.xz
 %endif
+# Apply proposed fix for CVE-2026-107080
+Patch0:         https://github.com/uclouvain/openjpeg/pull/1674.patch
 
 
 BuildRequires:  cmake
@@ -454,6 +456,9 @@ rm -rf %{buildroot}%{mingw64_datadir}/doc
 
 
 %changelog
+* Wed Oct 28 2026 Sandro Mani <manisandro@gmail.com> - 2.5.4-5
+- Apply proposed fix for CVE-2026-107080
+
 * Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.4-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-28 22:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 22:15 [rpms/openjpeg] f45: Apply proposed fix for CVE-2026-107080 Sandro Mani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox