summaryrefslogtreecommitdiff
path: root/media-libs/jbig2dec/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-08-25 10:45:55 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-08-25 10:45:55 +0100
commit3cf7c3ef441822c889356fd1812ebf2944a59851 (patch)
treec513fe68548b40365c1c2ebfe35c58ad431cdd77 /media-libs/jbig2dec/files
parent05b8b0e0af1d72e51a3ee61522941bf7605cd01c (diff)
gentoo resync : 25.08.2020
Diffstat (limited to 'media-libs/jbig2dec/files')
-rw-r--r--media-libs/jbig2dec/files/jbig2dec-0.17-fix-test_jbig2dec.py.patch39
-rw-r--r--media-libs/jbig2dec/files/jbig2dec-0.18-extra-overflow-checks.patch51
-rw-r--r--media-libs/jbig2dec/files/jbig2dec-0.18-overflow-IAID.patch36
3 files changed, 87 insertions, 39 deletions
diff --git a/media-libs/jbig2dec/files/jbig2dec-0.17-fix-test_jbig2dec.py.patch b/media-libs/jbig2dec/files/jbig2dec-0.17-fix-test_jbig2dec.py.patch
deleted file mode 100644
index e99a298f5de9..000000000000
--- a/media-libs/jbig2dec/files/jbig2dec-0.17-fix-test_jbig2dec.py.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From c48d802aa6f65cc0284c8aa9824b6ae4e7dd5aa1 Mon Sep 17 00:00:00 2001
-From: Sebastian Rasmussen <sebras@gmail.com>
-Date: Fri, 14 Jun 2019 22:18:14 +0200
-Subject: [PATCH] jbig2dec: Make tests expect that some test files return white
- image.
-
-Previously these tests would just error out and jbig2dec would not
-return any output file at all. Now, jbig2dec parses as much as
-possible, while emitting warning/error messages. In the case of a
-few of the test files the end result is a white image.
----
- test_jbig2dec.py | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/test_jbig2dec.py b/test_jbig2dec.py
-index a841438..33008e5 100755
---- a/test_jbig2dec.py
-+++ b/test_jbig2dec.py
-@@ -60,6 +60,7 @@ class KnownFileHash(SelfTest):
-
- # hashes of known test inputs
- known_NOTHING_DECODED = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
-+ known_WHITE_PAGE_DECODED = "28a6bd83a8a3a36910fbc1f5ce06c962e4332911"
- known_042_DECODED = "ebfdf6e2fc5ff3ee2271c2fa19de0e52712046e8"
- known_amb_DECODED = "3d4b7992d506894662b53415bd3d0d2a2f8b7953"
-
-@@ -103,10 +104,10 @@ class KnownFileHash(SelfTest):
- known_042_DECODED),
- ('../ubc/042_13.jb2',
- "7d428bd542f58591b254d9827f554b0552c950a7",
-- known_NOTHING_DECODED),
-+ known_WHITE_PAGE_DECODED),
- ('../ubc/042_14.jb2',
- "c40fe3a02acb6359baf9b40fc9c49bc0800be589",
-- known_NOTHING_DECODED),
-+ known_WHITE_PAGE_DECODED),
- ('../ubc/042_15.jb2',
- "a9e39fc1ecb178aec9f05039514d75ea3246246c",
- known_042_DECODED),
diff --git a/media-libs/jbig2dec/files/jbig2dec-0.18-extra-overflow-checks.patch b/media-libs/jbig2dec/files/jbig2dec-0.18-extra-overflow-checks.patch
new file mode 100644
index 000000000000..52a7f448e6f3
--- /dev/null
+++ b/media-libs/jbig2dec/files/jbig2dec-0.18-extra-overflow-checks.patch
@@ -0,0 +1,51 @@
+https://github.com/ArtifexSoftware/jbig2dec/commit/873694419b3498708b90c5c36ee0a73795a90c84
+----
+From 873694419b3498708b90c5c36ee0a73795a90c84 Mon Sep 17 00:00:00 2001
+From: Sebastian Rasmussen <sebras@gmail.com>
+Date: Sun, 15 Sep 2019 17:31:48 +0200
+Subject: [PATCH] jbig2dec: Handle under-/overflow detection and messaging
+ better.
+
+Previously SYMWIDTH was capped too early in order to prevent underflow
+Moreover TOTWIDTH was allowed to overflow.
+
+Now the value DW is checked compared to SYMWIDTH, preventing over
+underflow and overflow at the correct limits, and an overflow
+check has been added for TOTWIDTH.
+---
+ jbig2_symbol_dict.c | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/jbig2_symbol_dict.c b/jbig2_symbol_dict.c
+index e606529..bc6e98c 100644
+--- a/jbig2_symbol_dict.c
++++ b/jbig2_symbol_dict.c
+@@ -428,14 +428,24 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx,
+ break;
+ }
+
++ if (DW < 0 && SYMWIDTH < (uint32_t) -DW) {
++ code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "DW value (%d) would make SYMWIDTH (%u) negative at symbol %u", DW, SYMWIDTH, NSYMSDECODED + 1);
++ goto cleanup;
++ }
++ if (DW > 0 && DW > UINT32_MAX - SYMWIDTH) {
++ code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "DW value (%d) would make SYMWIDTH (%u) too large at symbol %u", DW, SYMWIDTH, NSYMSDECODED + 1);
++ goto cleanup;
++ }
++
+ SYMWIDTH = SYMWIDTH + DW;
+- TOTWIDTH = TOTWIDTH + SYMWIDTH;
+- if ((int32_t) SYMWIDTH < 0) {
+- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "invalid SYMWIDTH value (%d) at symbol %d", SYMWIDTH, NSYMSDECODED + 1);
++ if (SYMWIDTH > UINT32_MAX - TOTWIDTH) {
++ code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "SYMWIDTH value (%u) would make TOTWIDTH (%u) too large at symbol %u", SYMWIDTH, TOTWIDTH, NSYMSDECODED + 1);
+ goto cleanup;
+ }
++
++ TOTWIDTH = TOTWIDTH + SYMWIDTH;
+ #ifdef JBIG2_DEBUG
+- jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "SYMWIDTH = %d TOTWIDTH = %d", SYMWIDTH, TOTWIDTH);
++ jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "SYMWIDTH = %u TOTWIDTH = %u", SYMWIDTH, TOTWIDTH);
+ #endif
+ /* 6.5.5 (4c.ii) */
+ if (!params->SDHUFF || params->SDREFAGG) {
diff --git a/media-libs/jbig2dec/files/jbig2dec-0.18-overflow-IAID.patch b/media-libs/jbig2dec/files/jbig2dec-0.18-overflow-IAID.patch
new file mode 100644
index 000000000000..7205c980fc28
--- /dev/null
+++ b/media-libs/jbig2dec/files/jbig2dec-0.18-overflow-IAID.patch
@@ -0,0 +1,36 @@
+https://github.com/ArtifexSoftware/jbig2dec/commit/f6d326878893dc92b45cbd18e25ab4d2b3a8db73
+----
+From f6d326878893dc92b45cbd18e25ab4d2b3a8db73 Mon Sep 17 00:00:00 2001
+From: Sebastian Rasmussen <sebras@gmail.com>
+Date: Sun, 15 Sep 2019 18:12:31 +0200
+Subject: [PATCH] jbig2dec: Add overflow detection for IAID context size.
+
+---
+ jbig2_arith_iaid.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/jbig2_arith_iaid.c b/jbig2_arith_iaid.c
+index 78dc830..bbc38a0 100644
+--- a/jbig2_arith_iaid.c
++++ b/jbig2_arith_iaid.c
+@@ -44,9 +44,18 @@ struct _Jbig2ArithIaidCtx {
+ Jbig2ArithIaidCtx *
+ jbig2_arith_iaid_ctx_new(Jbig2Ctx *ctx, int SBSYMCODELEN)
+ {
+- Jbig2ArithIaidCtx *result = jbig2_new(ctx, Jbig2ArithIaidCtx, 1);
+- int ctx_size = 1 << SBSYMCODELEN;
++ Jbig2ArithIaidCtx *result;
++ size_t ctx_size;
+
++ if (sizeof(ctx_size) * 8 <= SBSYMCODELEN)
++ {
++ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "requested IAID arithmetic coding state size too large");
++ return NULL;
++ }
++
++ ctx_size = 1 << SBSYMCODELEN;
++
++ result = jbig2_new(ctx, Jbig2ArithIaidCtx, 1);
+ if (result == NULL) {
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate IAID arithmetic coding state");
+ return NULL;