summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2020-11-10 23:38:08 -0800
committerMichael Vrhel <michael.vrhel@artifex.com>2020-11-11 12:08:10 -0800
commit7d1f774ccf8d3c96dc9a40d317e1448cb5a6475a (patch)
treecb1d5195fc7118b81264611591fe88f740d43ca1 /contrib
parentd3a0d4c4c5e6c7c1662094500f25c11b27016268 (diff)
downloadghostpdl-7d1f774ccf8d3c96dc9a40d317e1448cb5a6475a.tar.gz
Bug 701804: Fix for device that causes buffer overflows
This contributed device is odd how it changes its color model. Unfortunately it does not change the ICC profile. This mismatch between the ICC profile and the color information that is being changed by the device causes all sorts of problems. This should fix the issue.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/gdevlx32.c79
1 files changed, 45 insertions, 34 deletions
diff --git a/contrib/gdevlx32.c b/contrib/gdevlx32.c
index b06c7ec1b..7cbd2b972 100644
--- a/contrib/gdevlx32.c
+++ b/contrib/gdevlx32.c
@@ -903,9 +903,6 @@ lxm3200_put_params(gx_device *pdev, gs_param_list *plist)
code = param_read_int(plist, "z31m", &z31m); /* What additional margin for the Z31 */
if(code < 0)return(code);
- code = gdev_prn_put_params(pdev, plist);
- if(code < 0)return code;
-
((lxm_device *)pdev)->algnA = algnA;
((lxm_device *)pdev)->algnB = algnB;
((lxm_device *)pdev)->algnC = algnC;
@@ -916,40 +913,54 @@ lxm3200_put_params(gx_device *pdev, gs_param_list *plist)
((lxm_device *)pdev)->model = model; /* Model selection: lxm3200, Z12, Z31. */
((lxm_device *)pdev)->z31m = z31m; /* Additional margin for the Z31 */
- /* Depending on the selected rendering mode, change the
- * driver's parameters that ghostscript needs for the
- * dithering. We need to do it here because the "get_params"
- * and "put_params" are the only routines in the driver that
- * ghostscript calls before using the dithering parameters.
- */
- switch(mode)
- {
- case LXM3200_M:
- pdev->color_info.num_components = 1;
- pdev->color_info.max_gray = 1;
- pdev->color_info.max_color = 0;
- pdev->color_info.dither_grays = 2;
- pdev->color_info.dither_colors = 0;
- break;
+ /* Depending on the selected rendering mode, change the
+ * driver's parameters that ghostscript needs for the
+ * dithering. We need to do it here because the "get_params"
+ * and "put_params" are the only routines in the driver that
+ * ghostscript calls before using the dithering parameters.
+ */
+ {
+ int old_num = pdev->color_info.num_components;
+
+ switch (mode)
+ {
+ case LXM3200_M:
+ pdev->color_info.num_components = 1;
+ pdev->color_info.max_gray = 1;
+ pdev->color_info.max_color = 0;
+ pdev->color_info.dither_grays = 2;
+ pdev->color_info.dither_colors = 0;
+ break;
- case LXM3200_C:
- pdev->color_info.num_components = 3;
- pdev->color_info.max_gray = 1;
- pdev->color_info.max_color = 1;
- pdev->color_info.dither_grays = 2;
- pdev->color_info.dither_colors = 2;
- break;
+ case LXM3200_C:
+ pdev->color_info.num_components = 3;
+ pdev->color_info.max_gray = 1;
+ pdev->color_info.max_color = 1;
+ pdev->color_info.dither_grays = 2;
+ pdev->color_info.dither_colors = 2;
+ break;
- case LXM3200_P:
- pdev->color_info.num_components = 3;
- pdev->color_info.max_gray = 1;
- pdev->color_info.max_color = 2;
- pdev->color_info.dither_grays = 2;
- pdev->color_info.dither_colors = 3;
- break;
- }
+ case LXM3200_P:
+ pdev->color_info.num_components = 3;
+ pdev->color_info.max_gray = 1;
+ pdev->color_info.max_color = 2;
+ pdev->color_info.dither_grays = 2;
+ pdev->color_info.dither_colors = 3;
+ break;
+ }
+ /* The above is horrid. But, if we change the color model
+ the ICC profile needs to change too. Blow away the
+ current structure. A new one will be built when we
+ go to gdev_prn_put_params. */
+ if (old_num != pdev->color_info.num_components) {
+ rc_decrement(pdev->icc_struct, "lxm3200_put_params");
+ pdev->icc_struct = NULL;
+ }
+ }
+
+ code = gdev_prn_put_params(pdev, plist);
- return 0;
+ return code;
}
/* --------- Internal routines --------- */