jasper: patch CVE-2023-51257
PATCH 1/4 jasper: patch CVE-2023-51257
Details: https://nvd.nist.gov/vuln/detail/CVE-2023-51257
Pick the patch that's marked to solve the issue linked in the nvd report.
Signed-off-by Gyorgy Sarvari <[email protected]>
--- .../jasper/jasper/CVE-2023-51257.patch | 40 +++++++++++++++++++ .../recipes-graphics/jasper/jasper_2.0.33.bb | 4 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-graphics/jasper/jasper/CVE-2023-51257.patch
meta-oe/recipes-graphics/jasper/jasper/CVE-2023-51257.patch new file +40 -0
@@ -0,0 +1,40 @@ +From b19a51001e681d6c4bbc32b43bd425dee7f2caff Mon Sep 17 00:00:00 2001 +From: Michael Adams <[email protected]> +Date: Thu, 14 Dec 2023 19:04:19 -0800 +Subject: [PATCH] Fixes #367. + +Fixed an integer-overflow bug in the ICC profile parsing code. +Added another invalid image to the test set. + +CVE: CVE-2023-51257 +Upstream-Status: Backport [https://github.com/jasper-software/jasper/commit/aeef5293c978158255ad4f127089644745602f2a] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/libjasper/base/jas_icc.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/libjasper/base/jas_icc.c b/src/libjasper/base/jas_icc.c +index 905b823..7e69bd4 100644 +--- a/src/libjasper/base/jas_icc.c ++++ b/src/libjasper/base/jas_icc.c +@@ -1295,10 +1295,20 @@ static int jas_icctxt_input(jas_iccattrval_t *attrval, jas_stream_t *in, + { + jas_icctxt_t *txt = &attrval->data.txt; + txt->string = 0; ++ /* The string must at least contain a single null character. */ ++ if (cnt < 1) { ++ goto error; ++ } + if (!(txt->string = jas_malloc(cnt))) + goto error; + if (jas_stream_read(in, txt->string, cnt) != cnt) + goto error; ++ /* Ensure that the string is null terminated. */ ++ if (txt->string[cnt - 1] != '\0') { ++ goto error; ++ } ++ /* The following line is redundant, unless we do not enforce that ++ the last character must be null. */ + txt->string[cnt - 1] = '\0'; + if (strlen(txt->string) + 1 != cnt) + goto error;
meta-oe/recipes-graphics/jasper/jasper_2.0.33.bb +3 -1
@@ -3,7 +3,9 @@ HOMEPAGE = "https://jasper-software.github.io/jasper/" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://LICENSE;md5=a80440d1d8f17d041c71c7271d6e06eb" -SRC_URI = "git://github.com/jasper-software/jasper.git;protocol=https;branch=master" +SRC_URI = "git://github.com/jasper-software/jasper.git;protocol=https;branch=master \ + file://CVE-2023-51257.patch \ + " SRCREV = "fe00207dc10db1d7cc6f2757961c5c6bdfd10973" CVE_CHECK_IGNORE += "\
PATCH 2/4 jasper: patch CVE-2025-8835
Details: https://nvd.nist.gov/vuln/detail/CVE-2025-8835
Pick the patch that is referenced by the nvd report.
Signed-off-by Gyorgy Sarvari <[email protected]>
--- .../jasper/jasper/CVE-2025-8835.patch | 170 ++++++++++++++++++ .../recipes-graphics/jasper/jasper_2.0.33.bb | 1 + 2 files changed, 171 insertions(+) create mode 100644 meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8835.patch
meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8835.patch new file +170 -0
@@ -0,0 +1,170 @@ +From 8c72f24556b2418f5689713eb706014423473a73 Mon Sep 17 00:00:00 2001 +From: Michael Adams <[email protected]> +Date: Tue, 29 Jul 2025 20:16:35 -0700 +Subject: [PATCH] Fixes #400. + +Added a check for a missing color component in the jas_image_chclrspc +function. + +CVE: CVE-2025-8835 +Upstream-Status: Backport [https://github.com/jasper-software/jasper/commit/bb7d62bd0a2a8e0e1fdb4d603f3305f955158c52] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/libjasper/base/jas_image.c | 73 ++++++++++++++++++++++++++++------ + 1 file changed, 61 insertions(+), 12 deletions(-) + +diff --git a/src/libjasper/base/jas_image.c b/src/libjasper/base/jas_image.c +index 68a94e1..bfbf9e5 100644 +--- a/src/libjasper/base/jas_image.c ++++ b/src/libjasper/base/jas_image.c +@@ -112,7 +112,8 @@ static long convert(long val, bool oldsgnd, unsigned oldprec, bool newsgnd, + unsigned newprec); + static void jas_image_calcbbox2(const jas_image_t *image, jas_image_coord_t *tlx, + jas_image_coord_t *tly, jas_image_coord_t *brx, jas_image_coord_t *bry); +- ++static jas_cmcmptfmt_t* jas_cmcmptfmt_array_create(int n); ++static void jas_cmcmptfmt_array_destroy(jas_cmcmptfmt_t* cmptfmts, int n); + /******************************************************************************\ + * Global data. + \******************************************************************************/ +@@ -409,6 +410,36 @@ static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt) + jas_free(cmpt); + } + ++static jas_cmcmptfmt_t* jas_cmcmptfmt_array_create(int n) ++{ ++ jas_cmcmptfmt_t* cmptfmts; ++ JAS_DBGLOG(10, ("jas_cmcmptfmt_array_create(%d)\n", n)); ++ if (!(cmptfmts = jas_alloc2(n, sizeof(jas_cmcmptfmt_t)))) { ++ return 0; ++ } ++ for (int i = 0; i < n; ++i) { ++ cmptfmts[i].buf = 0; ++ } ++ JAS_DBGLOG(10, ("jas_cmcmptfmt_array_create(%d) returning %p\n", n, ++ JAS_CAST(void *, cmptfmts))); ++ return cmptfmts; ++} ++ ++static void jas_cmcmptfmt_array_destroy(jas_cmcmptfmt_t* cmptfmts, int n) ++{ ++ assert(cmptfmts); ++ assert(n > 0); ++ JAS_DBGLOG(10, ("jas_cmcmptfmt_array_destroy(%p, %d)\n", ++ JAS_CAST(void *, cmptfmts), n)); ++ for (int i = 0; i < n; ++i) { ++ if (cmptfmts[i].buf) { ++ jas_free(cmptfmts[i].buf); ++ } ++ cmptfmts[i].buf = 0; ++ } ++ jas_free(cmptfmts); ++} ++ + /******************************************************************************\ + * Load and save operations. + \******************************************************************************/ +@@ -1470,12 +1501,15 @@ jas_image_t *jas_image_chclrspc(jas_image_t *image, const jas_cmprof_t *outprof, + jas_cmcmptfmt_t *incmptfmts; + jas_cmcmptfmt_t *outcmptfmts; + ++ assert(image); ++ assert(outprof); ++ + #if 0 + jas_eprintf("IMAGE\n"); + jas_image_dump(image, stderr); + #endif + +- if (image->numcmpts_ == 0) ++ if (!jas_image_numcmpts(image)) + /* can't work with a file with no components; + continuing would crash because we'd attempt to + obtain information about the first component */ +@@ -1483,6 +1517,8 @@ jas_image_dump(image, stderr); + + outimage = 0; + xform = 0; ++ incmptfmts = 0; ++ outcmptfmts = 0; + if (!(inimage = jas_image_copy(image))) + goto error; + image = 0; +@@ -1565,15 +1601,21 @@ jas_image_dump(image, stderr); + } + + inpixmap.numcmpts = numinclrchans; +- if (!(incmptfmts = jas_alloc2(numinclrchans, sizeof(jas_cmcmptfmt_t)))) { ++ assert(numinclrchans != 0); ++ if (!(incmptfmts = jas_cmcmptfmt_array_create(numinclrchans))) { + abort(); + } + inpixmap.cmptfmts = incmptfmts; + for (unsigned i = 0; i < numinclrchans; ++i) { + const int j = jas_image_getcmptbytype(inimage, JAS_IMAGE_CT_COLOR(i)); ++ if (j < 0) { ++ jas_eprintf("missing color component %d\n", i); ++ goto error; ++ } + if (!(incmptfmts[i].buf = jas_alloc2(width, sizeof(long)))) { + goto error; + } ++ assert(j >= 0 && j < jas_image_numcmpts(inimage)); + incmptfmts[i].prec = jas_image_cmptprec(inimage, j); + incmptfmts[i].sgnd = jas_image_cmptsgnd(inimage, j); + incmptfmts[i].width = width; +@@ -1581,15 +1623,20 @@ jas_image_dump(image, stderr); + } + + outpixmap.numcmpts = numoutclrchans; +- if (!(outcmptfmts = jas_alloc2(numoutclrchans, sizeof(jas_cmcmptfmt_t)))) { ++ if (!(outcmptfmts = jas_cmcmptfmt_array_create(numoutclrchans))) { + abort(); + } + outpixmap.cmptfmts = outcmptfmts; + + for (unsigned i = 0; i < numoutclrchans; ++i) { + const int j = jas_image_getcmptbytype(outimage, JAS_IMAGE_CT_COLOR(i)); ++ if (j < 0) { ++ jas_eprintf("missing color component %d\n", i); ++ goto error; ++ } + if (!(outcmptfmts[i].buf = jas_alloc2(width, sizeof(long)))) + goto error; ++ assert(j >= 0 && j < jas_image_numcmpts(outimage)); + outcmptfmts[i].prec = jas_image_cmptprec(outimage, j); + outcmptfmts[i].sgnd = jas_image_cmptsgnd(outimage, j); + outcmptfmts[i].width = width; +@@ -1612,14 +1659,8 @@ jas_image_dump(image, stderr); + } + } + +- for (unsigned i = 0; i < numoutclrchans; ++i) { +- jas_free(outcmptfmts[i].buf); +- } +- jas_free(outcmptfmts); +- for (unsigned i = 0; i < numinclrchans; ++i) { +- jas_free(incmptfmts[i].buf); +- } +- jas_free(incmptfmts); ++ jas_cmcmptfmt_array_destroy(outcmptfmts, numoutclrchans); ++ jas_cmcmptfmt_array_destroy(incmptfmts, numinclrchans); + jas_cmxform_destroy(xform); + jas_image_destroy(inimage); + +@@ -1631,6 +1672,14 @@ jas_image_dump(outimage, stderr); + #endif + return outimage; + error: ++ if (incmptfmts) { ++ assert(numinclrchans); ++ jas_cmcmptfmt_array_destroy(incmptfmts, numinclrchans); ++ } ++ if (outcmptfmts) { ++ assert(numoutclrchans); ++ jas_cmcmptfmt_array_destroy(outcmptfmts, numoutclrchans); ++ } + if (xform) + jas_cmxform_destroy(xform); + if (inimage)
meta-oe/recipes-graphics/jasper/jasper_2.0.33.bb +1 -0
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=a80440d1d8f17d041c71c7271d6e06eb" SRC_URI = "git://github.com/jasper-software/jasper.git;protocol=https;branch=master \ file://CVE-2023-51257.patch \ + file://CVE-2025-8835.patch \ " SRCREV = "fe00207dc10db1d7cc6f2757961c5c6bdfd10973"
PATCH 3/4 jasper: patch CVE-2025-8836
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2025-8836
Pick the patch that is referenced by the nvd report.
Signed-off-by Gyorgy Sarvari <[email protected]>
--- .../jasper/jasper/CVE-2025-8836.patch | 78 +++++++++++++++++++ .../recipes-graphics/jasper/jasper_2.0.33.bb | 1 + 2 files changed, 79 insertions(+) create mode 100644 meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8836.patch
meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8836.patch new file +78 -0
@@ -0,0 +1,78 @@ +From 0e045908b1fec6748688cbc13bd3dc3703ddb17e Mon Sep 17 00:00:00 2001 +From: Michael Adams <[email protected]> +Date: Sat, 2 Aug 2025 18:00:39 -0700 +Subject: [PATCH] Fixes #401. + +JPEG-2000 (JPC) Encoder: +- Added some missing range checking on several coding parameters + (e.g., precint width/height and codeblock width/height). + +CVE: CVE-2025-8836 +Upstream-Status: Backport [https://github.com/jasper-software/jasper/commit/79185d32d7a444abae441935b20ae4676b3513d4] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/libjasper/jpc/jpc_enc.c | 30 ++++++++++++++++++++++++------ + src/libjasper/jpc/jpc_t2dec.c | 3 ++- + 2 files changed, 26 insertions(+), 7 deletions(-) + +diff --git a/src/libjasper/jpc/jpc_enc.c b/src/libjasper/jpc/jpc_enc.c +index 93013f9..c957e3f 100644 +--- a/src/libjasper/jpc/jpc_enc.c ++++ b/src/libjasper/jpc/jpc_enc.c +@@ -474,18 +474,36 @@ static jpc_enc_cp_t *cp_create(const char *optstr, jas_image_t *image) + cp->tileheight = atoi(jas_tvparser_getval(tvp)); + break; + case OPT_PRCWIDTH: +- prcwidthexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp))); ++ i = atoi(jas_tvparser_getval(tvp)); ++ if (i <= 0) { ++ jas_eprintf("invalid precinct width (%d)\n", i); ++ goto error; ++ } ++ prcwidthexpn = jpc_floorlog2(i); + break; + case OPT_PRCHEIGHT: +- prcheightexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp))); ++ i = atoi(jas_tvparser_getval(tvp)); ++ if (i <= 0) { ++ jas_eprintf("invalid precinct height (%d)\n", i); ++ goto error; ++ } ++ prcheightexpn = jpc_floorlog2(i); + break; + case OPT_CBLKWIDTH: +- tccp->cblkwidthexpn = +- jpc_floorlog2(atoi(jas_tvparser_getval(tvp))); ++ i = atoi(jas_tvparser_getval(tvp)); ++ if (i <= 0) { ++ jas_eprintf("invalid code block width (%d)\n", i); ++ goto error; ++ } ++ tccp->cblkwidthexpn = jpc_floorlog2(i); + break; + case OPT_CBLKHEIGHT: +- tccp->cblkheightexpn = +- jpc_floorlog2(atoi(jas_tvparser_getval(tvp))); ++ i = atoi(jas_tvparser_getval(tvp)); ++ if (i <= 0) { ++ jas_eprintf("invalid code block height (%d)\n", i); ++ goto error; ++ } ++ tccp->cblkheightexpn = jpc_floorlog2(i); + break; + case OPT_MODE: + if ((tagid = jas_taginfo_nonull(jas_taginfos_lookup(modetab, +diff --git a/src/libjasper/jpc/jpc_t2dec.c b/src/libjasper/jpc/jpc_t2dec.c +index e52b549..6e1f1f7 100644 +--- a/src/libjasper/jpc/jpc_t2dec.c ++++ b/src/libjasper/jpc/jpc_t2dec.c +@@ -337,7 +337,8 @@ static int jpc_dec_decodepkt(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_str + const unsigned n = JAS_MIN((unsigned)numnewpasses, maxpasses); + mycounter += n; + numnewpasses -= n; +- if ((len = jpc_bitstream_getbits(inb, cblk->numlenbits + jpc_floorlog2(n))) < 0) { ++ if ((len = jpc_bitstream_getbits(inb, ++ cblk->numlenbits + jpc_floorlog2(n))) < 0) { + jpc_bitstream_close(inb); + return -1; + }
meta-oe/recipes-graphics/jasper/jasper_2.0.33.bb +1 -0
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=a80440d1d8f17d041c71c7271d6e06eb" SRC_URI = "git://github.com/jasper-software/jasper.git;protocol=https;branch=master \ file://CVE-2023-51257.patch \ file://CVE-2025-8835.patch \ + file://CVE-2025-8836.patch \ " SRCREV = "fe00207dc10db1d7cc6f2757961c5c6bdfd10973"
PATCH 4/4 jasper: patch CVE-2025-8837
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2025-8837
Pick the patch that is referenced by the nvd report.
Signed-off-by Gyorgy Sarvari <[email protected]>
--- .../jasper/jasper/CVE-2025-8837.patch | 63 +++++++++++++++++++ .../recipes-graphics/jasper/jasper_2.0.33.bb | 1 + 2 files changed, 64 insertions(+) create mode 100644 meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8837.patch
meta-oe/recipes-graphics/jasper/jasper/CVE-2025-8837.patch new file +63 -0
@@ -0,0 +1,63 @@ +From 61c37530a3abcb5db2f7a431e91dbb3531ff1816 Mon Sep 17 00:00:00 2001 +From: Michael Adams <[email protected]> +Date: Tue, 5 Aug 2025 20:46:48 -0700 +Subject: [PATCH] Fixes #402, #403. + +JPEG-2000 (JPC) Decoder: +- Added the setting of several pointers to null in some cleanup code + after the pointed-to memory was freed. This pointer nulling is not + needed normally, but it is needed when certain debugging logs are + enabled (so that the debug code understands that the memory associated + with the aforementioned pointers has been freed). + +CVE: CVE-2025-8837 +Upstream-Status: Backport [https://github.com/jasper-software/jasper/commit/8308060d3fbc1da10353ac8a95c8ea60eba9c25a] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/libjasper/jpc/jpc_dec.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/src/libjasper/jpc/jpc_dec.c b/src/libjasper/jpc/jpc_dec.c +index 2553696..c2600c4 100644 +--- a/src/libjasper/jpc/jpc_dec.c ++++ b/src/libjasper/jpc/jpc_dec.c +@@ -1107,23 +1107,23 @@ static int jpc_dec_tilefini(jpc_dec_t *dec, jpc_dec_tile_t *tile) + + if (tile->cp) { + jpc_dec_cp_destroy(tile->cp); +- //tile->cp = 0; ++ tile->cp = 0; + } + if (tile->tcomps) { + jas_free(tile->tcomps); +- //tile->tcomps = 0; ++ tile->tcomps = 0; + } + if (tile->pi) { + jpc_pi_destroy(tile->pi); +- //tile->pi = 0; ++ tile->pi = 0; + } + if (tile->pkthdrstream) { + jas_stream_close(tile->pkthdrstream); +- //tile->pkthdrstream = 0; ++ tile->pkthdrstream = 0; + } + if (tile->pptstab) { + jpc_ppxstab_destroy(tile->pptstab); +- //tile->pptstab = 0; ++ tile->pptstab = 0; + } + + tile->state = JPC_TILE_DONE; +@@ -2259,6 +2259,9 @@ static int jpc_dec_dump(const jpc_dec_t *dec, FILE *out) + const jpc_dec_tile_t *tile; + for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; + ++tileno, ++tile) { ++ if (!tile->tcomps) { ++ continue; ++ } + assert(!dec->numcomps || tile->tcomps); + unsigned compno; + const jpc_dec_tcomp_t *tcomp;
meta-oe/recipes-graphics/jasper/jasper_2.0.33.bb +1 -0
@@ -7,6 +7,7 @@ SRC_URI = "git://github.com/jasper-software/jasper.git;protocol=https;branch=mas file://CVE-2023-51257.patch \ file://CVE-2025-8835.patch \ file://CVE-2025-8836.patch \ + file://CVE-2025-8837.patch \ " SRCREV = "fe00207dc10db1d7cc6f2757961c5c6bdfd10973"