From 310da4ed563eafebd97a67d22aa449318c8fe1bc Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 19 Oct 2022 11:00:19 +0200 Subject: [PATCH] fix specifix shading subfunction handling gs bug 705225 gs commit bb53c6400abf474feb50125a4e438338fc6ba000 --- ...per-bounds-check-for-subfunctions-of.patch | 76 +++++++++++++++++++ ghostscript.spec | 6 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 ghostscript-9.56.1-use-proper-bounds-check-for-subfunctions-of.patch diff --git a/ghostscript-9.56.1-use-proper-bounds-check-for-subfunctions-of.patch b/ghostscript-9.56.1-use-proper-bounds-check-for-subfunctions-of.patch new file mode 100644 index 0000000..8d3e700 --- /dev/null +++ b/ghostscript-9.56.1-use-proper-bounds-check-for-subfunctions-of.patch @@ -0,0 +1,76 @@ +From 61ee992bf2e132da2168754f587fcf163a68eb12 Mon Sep 17 00:00:00 2001 +Message-Id: <61ee992bf2e132da2168754f587fcf163a68eb12.1666169658.git.mjg@fedoraproject.org> +From: Ken Sharp +Date: Thu, 19 May 2022 16:59:05 +0100 +Subject: [PATCH] GhostPDF - use proper bounds check for subfunctions of type 3 + +Bug #705225 "Gradients not rendered with the new PDF interpreter" + +The files in question have some remarkably complicated functions used +to define a shading. One has a type 3 stitching function with 33 type 2 +subfunctions, to define basically a blue fill.... + +The Domain of the shading is, additionally, unusual ranging from +negative to positive instead of the more usual 0 to N for the parametric +variable. + +The problem is that we were comparing the Domain of each subfunction +against the Domain of the shading function, when in fact each sub +function uses the relevant Encode parameter of the type 3 function +and it is this that we should be checking against the Domain of the sub +function. +--- + pdf/pdf_func.c | 25 +++++++++++++------------ + 1 file changed, 13 insertions(+), 12 deletions(-) + +diff --git a/pdf/pdf_func.c b/pdf/pdf_func.c +index 9537152ed..6e2d4e4e9 100644 +--- a/pdf/pdf_func.c ++++ b/pdf/pdf_func.c +@@ -560,6 +560,18 @@ pdfi_build_function_3(pdf_context *ctx, gs_function_params_t * mnDR, + + params.Functions = (const gs_function_t * const *)ptr; + ++ code = pdfi_make_float_array_from_dict(ctx, (float **)¶ms.Bounds, function_dict, "Bounds"); ++ if (code < 0) ++ goto function_3_error; ++ ++ code = pdfi_make_float_array_from_dict(ctx, (float **)¶ms.Encode, function_dict, "Encode"); ++ if (code < 0) ++ goto function_3_error; ++ ++ if (code != 2 * params.k) ++ goto function_3_error; ++ code = 0; ++ + for (i = 0; i < params.k; ++i) { + pdf_obj * rsubfn = NULL; + +@@ -578,23 +590,12 @@ pdfi_build_function_3(pdf_context *ctx, gs_function_params_t * mnDR, + if (code < 0) + goto function_3_error; + +- code = pdfi_build_sub_function(ctx, &ptr[i], shading_domain, num_inputs, rsubfn, page_dict); ++ code = pdfi_build_sub_function(ctx, &ptr[i], ¶ms.Encode[i * 2], num_inputs, rsubfn, page_dict); + pdfi_countdown(rsubfn); + if (code < 0) + goto function_3_error; + } + +- code = pdfi_make_float_array_from_dict(ctx, (float **)¶ms.Bounds, function_dict, "Bounds"); +- if (code < 0) +- goto function_3_error; +- +- code = pdfi_make_float_array_from_dict(ctx, (float **)¶ms.Encode, function_dict, "Encode"); +- if (code < 0) +- goto function_3_error; +- +- if (code != 2 * params.k) +- goto function_3_error; +- + if (params.Range == 0) + params.n = params.Functions[0]->params.n; + +-- +2.38.0.124.g8fc341881c + diff --git a/ghostscript.spec b/ghostscript.spec index e1e1918..f5a62ea 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -45,7 +45,7 @@ Name: ghostscript Summary: Interpreter for PostScript language & PDF Version: 9.56.1 -Release: 3%{?dist} +Release: 4%{?dist} License: AGPLv3+ @@ -105,6 +105,7 @@ BuildRequires: make #Patch000: example000.patch Patch000: ghostscript-9.56-fix-PDFFitPage-with-square-MediaBox.patch Patch001: ghostscript-9.56.1-Fix-color-info-juggling-with-x11-devices.patch +Patch002: ghostscript-9.56.1-use-proper-bounds-check-for-subfunctions-of.patch # Downstream patches -- these should be always included when doing rebase: # ------------------ @@ -435,6 +436,9 @@ done # ============================================================================= %changelog +* Wed Oct 19 2022 Michael J Gruber - 9.56.1-4 +- fix specifix shading subfunction handling + * Wed Oct 05 2022 Michael J Gruber - 9.56.1-3 - fix segfaulting X11 devices (rhbz#2125654)