|
|
ea5d11 |
From 3a0439ded9a206060f560bd6784942adeab759ff Mon Sep 17 00:00:00 2001
|
|
|
ea5d11 |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
ea5d11 |
Date: Thu, 27 Apr 2017 13:03:33 +0100
|
|
|
ea5d11 |
Subject: [PATCH 1/4] Bug 697799: have .eqproc check its parameters
|
|
|
ea5d11 |
|
|
|
ea5d11 |
The Ghostscript custom operator .eqproc was not check the number or type of
|
|
|
ea5d11 |
the parameters it was given.
|
|
|
ea5d11 |
---
|
|
|
ea5d11 |
psi/zmisc3.c | 6 ++++++
|
|
|
ea5d11 |
1 file changed, 6 insertions(+)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
diff --git a/psi/zmisc3.c b/psi/zmisc3.c
|
|
|
ea5d11 |
index 54b3042..0d357f1 100644
|
|
|
ea5d11 |
--- a/psi/zmisc3.c
|
|
|
ea5d11 |
+++ b/psi/zmisc3.c
|
|
|
ea5d11 |
@@ -56,6 +56,12 @@ zeqproc(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
ref2_t stack[MAX_DEPTH + 1];
|
|
|
ea5d11 |
ref2_t *top = stack;
|
|
|
ea5d11 |
|
|
|
ea5d11 |
+ if (ref_stack_count(&o_stack) < 2)
|
|
|
ea5d11 |
+ return_error(e_stackunderflow);
|
|
|
ea5d11 |
+ if (!r_is_array(op - 1) || !r_is_array(op)) {
|
|
|
ea5d11 |
+ return_error(e_typecheck);
|
|
|
ea5d11 |
+ }
|
|
|
ea5d11 |
+
|
|
|
ea5d11 |
make_array(&stack[0].proc1, 0, 1, op - 1);
|
|
|
ea5d11 |
make_array(&stack[0].proc2, 0, 1, op);
|
|
|
ea5d11 |
for (;;) {
|
|
|
ea5d11 |
--
|
|
|
ea5d11 |
2.9.3
|
|
|
ea5d11 |
|
|
|
ea5d11 |
|
|
|
ea5d11 |
From 9040e08c62422937c27fa5179657fbe3690809f3 Mon Sep 17 00:00:00 2001
|
|
|
ea5d11 |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
ea5d11 |
Date: Thu, 27 Apr 2017 13:21:31 +0100
|
|
|
ea5d11 |
Subject: [PATCH 2/4] Bug 697799: have .rsdparams check its parameters
|
|
|
ea5d11 |
|
|
|
ea5d11 |
The Ghostscript internal operator .rsdparams wasn't checking the number or
|
|
|
ea5d11 |
type of the operands it was being passed. Do so.
|
|
|
ea5d11 |
---
|
|
|
ea5d11 |
psi/zfrsd.c | 22 +++++++++++++++-------
|
|
|
ea5d11 |
1 file changed, 15 insertions(+), 7 deletions(-)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
diff --git a/psi/zfrsd.c b/psi/zfrsd.c
|
|
|
ea5d11 |
index fb4bce9..2629afa 100644
|
|
|
ea5d11 |
--- a/psi/zfrsd.c
|
|
|
ea5d11 |
+++ b/psi/zfrsd.c
|
|
|
ea5d11 |
@@ -49,13 +49,20 @@ zrsdparams(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
ref *pFilter;
|
|
|
ea5d11 |
ref *pDecodeParms;
|
|
|
ea5d11 |
int Intent = 0;
|
|
|
ea5d11 |
- bool AsyncRead;
|
|
|
ea5d11 |
+ bool AsyncRead = false;
|
|
|
ea5d11 |
ref empty_array, filter1_array, parms1_array;
|
|
|
ea5d11 |
uint i;
|
|
|
ea5d11 |
- int code;
|
|
|
ea5d11 |
+ int code = 0;
|
|
|
ea5d11 |
+
|
|
|
ea5d11 |
+ if (ref_stack_count(&o_stack) < 1)
|
|
|
ea5d11 |
+ return_error(e_stackunderflow);
|
|
|
ea5d11 |
+ if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) {
|
|
|
ea5d11 |
+ return_error(e_typecheck);
|
|
|
ea5d11 |
+ }
|
|
|
ea5d11 |
|
|
|
ea5d11 |
make_empty_array(&empty_array, a_readonly);
|
|
|
ea5d11 |
- if (dict_find_string(op, "Filter", &pFilter) > 0) {
|
|
|
ea5d11 |
+ if (r_has_type(op, t_dictionary)
|
|
|
ea5d11 |
+ && dict_find_string(op, "Filter", &pFilter) > 0) {
|
|
|
ea5d11 |
if (!r_is_array(pFilter)) {
|
|
|
ea5d11 |
if (!r_has_type(pFilter, t_name))
|
|
|
ea5d11 |
return_error(e_typecheck);
|
|
|
ea5d11 |
@@ -94,12 +101,13 @@ zrsdparams(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
return_error(e_typecheck);
|
|
|
ea5d11 |
}
|
|
|
ea5d11 |
}
|
|
|
ea5d11 |
- code = dict_int_param(op, "Intent", 0, 3, 0, &Intent);
|
|
|
ea5d11 |
+ if (r_has_type(op, t_dictionary))
|
|
|
ea5d11 |
+ code = dict_int_param(op, "Intent", 0, 3, 0, &Intent);
|
|
|
ea5d11 |
if (code < 0 && code != e_rangecheck) /* out-of-range int is ok, use 0 */
|
|
|
ea5d11 |
return code;
|
|
|
ea5d11 |
- if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0
|
|
|
ea5d11 |
- )
|
|
|
ea5d11 |
- return code;
|
|
|
ea5d11 |
+ if (r_has_type(op, t_dictionary))
|
|
|
ea5d11 |
+ if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0)
|
|
|
ea5d11 |
+ return code;
|
|
|
ea5d11 |
push(1);
|
|
|
ea5d11 |
op[-1] = *pFilter;
|
|
|
ea5d11 |
if (pDecodeParms)
|
|
|
ea5d11 |
--
|
|
|
ea5d11 |
2.9.3
|
|
|
ea5d11 |
|
|
|
ea5d11 |
|
|
|
ea5d11 |
From ba6c38c25e8c0ece91c47d96578f3f7a0e6c4e6c Mon Sep 17 00:00:00 2001
|
|
|
ea5d11 |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
ea5d11 |
Date: Wed, 3 May 2017 12:05:45 +0100
|
|
|
ea5d11 |
Subject: [PATCH 3/4] Bug 697846: revision to commit 4f83478c88 (.eqproc)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
When using the "DELAYBIND" feature, it turns out that .eqproc can be called with
|
|
|
ea5d11 |
parameters that are not both procedures. In this case, it turns out, the
|
|
|
ea5d11 |
expectation is for the operator to return 'false', rather than throw an error.
|
|
|
ea5d11 |
---
|
|
|
ea5d11 |
psi/zmisc3.c | 15 +++++++++++++--
|
|
|
ea5d11 |
1 file changed, 13 insertions(+), 2 deletions(-)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
diff --git a/psi/zmisc3.c b/psi/zmisc3.c
|
|
|
ea5d11 |
index 0d357f1..9042908 100644
|
|
|
ea5d11 |
--- a/psi/zmisc3.c
|
|
|
ea5d11 |
+++ b/psi/zmisc3.c
|
|
|
ea5d11 |
@@ -38,6 +38,15 @@ zcliprestore(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
return gs_cliprestore(igs);
|
|
|
ea5d11 |
}
|
|
|
ea5d11 |
|
|
|
ea5d11 |
+static inline bool
|
|
|
ea5d11 |
+eqproc_check_type(ref *r)
|
|
|
ea5d11 |
+{
|
|
|
ea5d11 |
+ return r_has_type(r, t_array)
|
|
|
ea5d11 |
+ || r_has_type(r, t_mixedarray)
|
|
|
ea5d11 |
+ || r_has_type(r, t_shortarray)
|
|
|
ea5d11 |
+ || r_has_type(r, t_oparray);
|
|
|
ea5d11 |
+}
|
|
|
ea5d11 |
+
|
|
|
ea5d11 |
/* <proc1> <proc2> .eqproc <bool> */
|
|
|
ea5d11 |
/*
|
|
|
ea5d11 |
* Test whether two procedures are equal to depth 10.
|
|
|
ea5d11 |
@@ -58,8 +67,10 @@ zeqproc(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
if (ref_stack_count(&o_stack) < 2)
|
|
|
ea5d11 |
return_error(e_stackunderflow);
|
|
|
ea5d11 |
- if (!r_is_array(op - 1) || !r_is_array(op)) {
|
|
|
ea5d11 |
- return_error(e_typecheck);
|
|
|
ea5d11 |
+ if (!eqproc_check_type(op -1) || !eqproc_check_type(op)) {
|
|
|
ea5d11 |
+ make_false(op - 1);
|
|
|
ea5d11 |
+ pop(1);
|
|
|
ea5d11 |
+ return 0;
|
|
|
ea5d11 |
}
|
|
|
ea5d11 |
|
|
|
ea5d11 |
make_array(&stack[0].proc1, 0, 1, op - 1);
|
|
|
ea5d11 |
--
|
|
|
ea5d11 |
2.9.3
|
|
|
ea5d11 |
|
|
|
ea5d11 |
|
|
|
ea5d11 |
From ae3fdbd05b0e654273402e7391288a091a1c0a9e Mon Sep 17 00:00:00 2001
|
|
|
ea5d11 |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
ea5d11 |
Date: Thu, 11 May 2017 14:07:48 +0100
|
|
|
ea5d11 |
Subject: [PATCH 4/4] Bug 697892: fix check for op stack underflow.
|
|
|
ea5d11 |
|
|
|
ea5d11 |
In the original fix, I used the wrong method to check for stack underflow, this
|
|
|
ea5d11 |
is using the correct method.
|
|
|
ea5d11 |
---
|
|
|
ea5d11 |
psi/zfrsd.c | 3 +--
|
|
|
ea5d11 |
psi/zmisc3.c | 3 +--
|
|
|
ea5d11 |
2 files changed, 2 insertions(+), 4 deletions(-)
|
|
|
ea5d11 |
|
|
|
ea5d11 |
diff --git a/psi/zfrsd.c b/psi/zfrsd.c
|
|
|
ea5d11 |
index 2629afa..fd9872e 100644
|
|
|
ea5d11 |
--- a/psi/zfrsd.c
|
|
|
ea5d11 |
+++ b/psi/zfrsd.c
|
|
|
ea5d11 |
@@ -54,8 +54,7 @@ zrsdparams(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
uint i;
|
|
|
ea5d11 |
int code = 0;
|
|
|
ea5d11 |
|
|
|
ea5d11 |
- if (ref_stack_count(&o_stack) < 1)
|
|
|
ea5d11 |
- return_error(e_stackunderflow);
|
|
|
ea5d11 |
+ check_op(1);
|
|
|
ea5d11 |
if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) {
|
|
|
ea5d11 |
return_error(e_typecheck);
|
|
|
ea5d11 |
}
|
|
|
ea5d11 |
diff --git a/psi/zmisc3.c b/psi/zmisc3.c
|
|
|
ea5d11 |
index 9042908..43803b5 100644
|
|
|
ea5d11 |
--- a/psi/zmisc3.c
|
|
|
ea5d11 |
+++ b/psi/zmisc3.c
|
|
|
ea5d11 |
@@ -65,8 +65,7 @@ zeqproc(i_ctx_t *i_ctx_p)
|
|
|
ea5d11 |
ref2_t stack[MAX_DEPTH + 1];
|
|
|
ea5d11 |
ref2_t *top = stack;
|
|
|
ea5d11 |
|
|
|
ea5d11 |
- if (ref_stack_count(&o_stack) < 2)
|
|
|
ea5d11 |
- return_error(e_stackunderflow);
|
|
|
ea5d11 |
+ check_op(2);
|
|
|
ea5d11 |
if (!eqproc_check_type(op -1) || !eqproc_check_type(op)) {
|
|
|
ea5d11 |
make_false(op - 1);
|
|
|
ea5d11 |
pop(1);
|
|
|
ea5d11 |
--
|
|
|
ea5d11 |
2.9.3
|
|
|
ea5d11 |
|