summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2017-04-27 13:21:31 +0100
committerChris Liddell <chris.liddell@artifex.com>2017-04-27 16:28:50 +0100
commit04b37bbce174eed24edec7ad5b920eb93db4d47d (patch)
treee9c83141c70102a5d4a3a47ab0beba3dc90b7986
parent4f83478c88c2e05d6e8d79ca4557eb039354d2f3 (diff)
Bug 697799: have .rsdparams check its parameters
The Ghostscript internal operator .rsdparams wasn't checking the number or type of the operands it was being passed. Do so.
-rw-r--r--psi/zfrsd.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/psi/zfrsd.c b/psi/zfrsd.c
index 191107d8a..950588d69 100644
--- a/psi/zfrsd.c
+++ b/psi/zfrsd.c
@@ -49,13 +49,20 @@ zrsdparams(i_ctx_t *i_ctx_p)
49 ref *pFilter; 49 ref *pFilter;
50 ref *pDecodeParms; 50 ref *pDecodeParms;
51 int Intent = 0; 51 int Intent = 0;
52 bool AsyncRead; 52 bool AsyncRead = false;
53 ref empty_array, filter1_array, parms1_array; 53 ref empty_array, filter1_array, parms1_array;
54 uint i; 54 uint i;
55 int code; 55 int code = 0;
56
57 if (ref_stack_count(&o_stack) < 1)
58 return_error(gs_error_stackunderflow);
59 if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) {
60 return_error(gs_error_typecheck);
61 }
56 62
57 make_empty_array(&empty_array, a_readonly); 63 make_empty_array(&empty_array, a_readonly);
58 if (dict_find_string(op, "Filter", &pFilter) > 0) { 64 if (r_has_type(op, t_dictionary)
65 && dict_find_string(op, "Filter", &pFilter) > 0) {
59 if (!r_is_array(pFilter)) { 66 if (!r_is_array(pFilter)) {
60 if (!r_has_type(pFilter, t_name)) 67 if (!r_has_type(pFilter, t_name))
61 return_error(gs_error_typecheck); 68 return_error(gs_error_typecheck);
@@ -94,12 +101,13 @@ zrsdparams(i_ctx_t *i_ctx_p)
94 return_error(gs_error_typecheck); 101 return_error(gs_error_typecheck);
95 } 102 }
96 } 103 }
97 code = dict_int_param(op, "Intent", 0, 3, 0, &Intent); 104 if (r_has_type(op, t_dictionary))
105 code = dict_int_param(op, "Intent", 0, 3, 0, &Intent);
98 if (code < 0 && code != gs_error_rangecheck) /* out-of-range int is ok, use 0 */ 106 if (code < 0 && code != gs_error_rangecheck) /* out-of-range int is ok, use 0 */
99 return code; 107 return code;
100 if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0 108 if (r_has_type(op, t_dictionary))
101 ) 109 if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0)
102 return code; 110 return code;
103 push(1); 111 push(1);
104 op[-1] = *pFilter; 112 op[-1] = *pFilter;
105 if (pDecodeParms) 113 if (pDecodeParms)