|
|
a60c09 |
From fac7eb144135f3ed8fbb0028ab1f33ce4dcc1985 Mon Sep 17 00:00:00 2001
|
|
|
a60c09 |
From: Ken Sharp <ken.sharp@artifex.com>
|
|
|
a60c09 |
Date: Fri, 21 Sep 2018 13:02:56 +0100
|
|
|
a60c09 |
Subject: [PATCH 1/3] Check all uses of dict_find* to ensure 0 return properly
|
|
|
a60c09 |
handled
|
|
|
a60c09 |
|
|
|
a60c09 |
dict_find and friends have the surprising quirk of returning < 0 for
|
|
|
a60c09 |
an error and > 0 for no error. But they can also return 0 which means
|
|
|
a60c09 |
'not found' without it being an error.
|
|
|
a60c09 |
|
|
|
a60c09 |
From bug 699801, if the code assumes the usual case where 0 is a success
|
|
|
a60c09 |
then an attempt might be made to use the empty dictionary slot returned
|
|
|
a60c09 |
by dict_find*, which can lead to seg faults, and certainly won't have
|
|
|
a60c09 |
the expected result.
|
|
|
a60c09 |
---
|
|
|
a60c09 |
psi/icontext.c | 4 ++--
|
|
|
a60c09 |
psi/zcid.c | 6 ++++--
|
|
|
a60c09 |
psi/zfapi.c | 33 ++++++++++++++++++---------------
|
|
|
a60c09 |
psi/zfcid0.c | 39 +++++++++++++++++++++++++++++----------
|
|
|
a60c09 |
psi/zfcid1.c | 14 ++++++++++----
|
|
|
a60c09 |
psi/zicc.c | 4 ++++
|
|
|
a60c09 |
psi/zpdf_r6.c | 31 +++++++++++++++++++++++--------
|
|
|
a60c09 |
psi/ztoken.c | 2 +-
|
|
|
a60c09 |
8 files changed, 91 insertions(+), 42 deletions(-)
|
|
|
a60c09 |
|
|
|
a60c09 |
diff --git a/psi/icontext.c b/psi/icontext.c
|
|
|
a60c09 |
index 4db78e0..1fbe486 100644
|
|
|
a60c09 |
--- a/psi/icontext.c
|
|
|
a60c09 |
+++ b/psi/icontext.c
|
|
|
a60c09 |
@@ -162,7 +162,7 @@ context_state_alloc(gs_context_state_t ** ppcst,
|
|
|
a60c09 |
uint size;
|
|
|
a60c09 |
ref *system_dict = &pcst->dict_stack.system_dict;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (dict_find_string(system_dict, "userparams", &puserparams) >= 0)
|
|
|
a60c09 |
+ if (dict_find_string(system_dict, "userparams", &puserparams) > 0)
|
|
|
a60c09 |
size = dict_length(puserparams);
|
|
|
a60c09 |
else
|
|
|
a60c09 |
size = 300;
|
|
|
a60c09 |
@@ -286,7 +286,7 @@ context_state_store(gs_context_state_t * pcst)
|
|
|
a60c09 |
/* We need i_ctx_p for access to the d_stack. */
|
|
|
a60c09 |
i_ctx_t *i_ctx_p = pcst;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (dict_find_string(systemdict, "userparams", &puserparams) < 0)
|
|
|
a60c09 |
+ if (dict_find_string(systemdict, "userparams", &puserparams) <= 0)
|
|
|
a60c09 |
return_error(gs_error_Fatal);
|
|
|
a60c09 |
pcst->userparams = *puserparams;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
diff --git a/psi/zcid.c b/psi/zcid.c
|
|
|
a60c09 |
index e394877..5c98fc9 100644
|
|
|
a60c09 |
--- a/psi/zcid.c
|
|
|
a60c09 |
+++ b/psi/zcid.c
|
|
|
a60c09 |
@@ -72,11 +72,13 @@ TT_char_code_from_CID_no_subst(const gs_memory_t *mem,
|
|
|
a60c09 |
} else
|
|
|
a60c09 |
return false; /* Must not happen. */
|
|
|
a60c09 |
for (;n--; i++) {
|
|
|
a60c09 |
+ int code;
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if (array_get(mem, DecodingArray, i, &char_code1) < 0 ||
|
|
|
a60c09 |
!r_has_type(&char_code1, t_integer))
|
|
|
a60c09 |
return false; /* Must not happen. */
|
|
|
a60c09 |
- if (dict_find(TT_cmap, &char_code1, &glyph_index) >= 0 &&
|
|
|
a60c09 |
- r_has_type(glyph_index, t_integer)) {
|
|
|
a60c09 |
+ code = dict_find(TT_cmap, &char_code1, &glyph_index);
|
|
|
a60c09 |
+ if (code > 0 && r_has_type(glyph_index, t_integer)) {
|
|
|
a60c09 |
*c = glyph_index->value.intval;
|
|
|
a60c09 |
found = true;
|
|
|
a60c09 |
if (*c != 0)
|
|
|
a60c09 |
diff --git a/psi/zfapi.c b/psi/zfapi.c
|
|
|
a60c09 |
index 48e1d54..1b687b0 100644
|
|
|
a60c09 |
--- a/psi/zfapi.c
|
|
|
a60c09 |
+++ b/psi/zfapi.c
|
|
|
a60c09 |
@@ -1826,6 +1826,9 @@ FAPI_get_xlatmap(i_ctx_t *i_ctx_p, char **xlatmap)
|
|
|
a60c09 |
|
|
|
a60c09 |
if ((code = dict_find_string(systemdict, ".xlatmap", &pref)) < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if (r_type(pref) != t_string)
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
*xlatmap = (char *)pref->value.bytes;
|
|
|
a60c09 |
@@ -1881,11 +1884,11 @@ ps_get_server_param(gs_fapi_server *I, const byte *subtype,
|
|
|
a60c09 |
ref *FAPIconfig, *options, *server_options;
|
|
|
a60c09 |
i_ctx_t *i_ctx_p = (i_ctx_t *) I->client_ctx_p;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (dict_find_string(systemdict, ".FAPIconfig", &FAPIconfig) >= 0
|
|
|
a60c09 |
+ if (dict_find_string(systemdict, ".FAPIconfig", &FAPIconfig) > 0
|
|
|
a60c09 |
&& r_has_type(FAPIconfig, t_dictionary)) {
|
|
|
a60c09 |
- if (dict_find_string(FAPIconfig, "ServerOptions", &options) >= 0
|
|
|
a60c09 |
+ if (dict_find_string(FAPIconfig, "ServerOptions", &options) > 0
|
|
|
a60c09 |
&& r_has_type(options, t_dictionary)) {
|
|
|
a60c09 |
- if (dict_find_string(options, (char *)subtype, &server_options) >=
|
|
|
a60c09 |
+ if (dict_find_string(options, (char *)subtype, &server_options) >
|
|
|
a60c09 |
0 && r_has_type(server_options, t_string)) {
|
|
|
a60c09 |
*server_param = (byte *) server_options->value.const_bytes;
|
|
|
a60c09 |
*server_param_size = r_size(server_options);
|
|
|
a60c09 |
@@ -2070,7 +2073,7 @@ zFAPIrebuildfont(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
pdata = (font_data *) pfont->client_data;
|
|
|
a60c09 |
I = pbfont->FAPI;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (dict_find_string((op - 1), "SubfontId", &v) >= 0
|
|
|
a60c09 |
+ if (dict_find_string((op - 1), "SubfontId", &v) > 0
|
|
|
a60c09 |
&& r_has_type(v, t_integer))
|
|
|
a60c09 |
subfont = v->value.intval;
|
|
|
a60c09 |
else
|
|
|
a60c09 |
@@ -2277,8 +2280,8 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum,
|
|
|
a60c09 |
if (pbfont->FontType == ft_CID_TrueType && font_file_path) {
|
|
|
a60c09 |
ref *pdr2, *fidr, *dummy;
|
|
|
a60c09 |
pdr2 = pfont_dict(gs_rootfont(igs));
|
|
|
a60c09 |
- if (dict_find_string(pdr2, "FontInfo", &fidr) &&
|
|
|
a60c09 |
- dict_find_string(fidr, "GlyphNames2Unicode", &dummy))
|
|
|
a60c09 |
+ if (dict_find_string(pdr2, "FontInfo", &fidr) > 0 &&
|
|
|
a60c09 |
+ dict_find_string(fidr, "GlyphNames2Unicode", &dummy) > 0)
|
|
|
a60c09 |
{
|
|
|
a60c09 |
unsigned char uc[4] = {0};
|
|
|
a60c09 |
unsigned int cc = 0;
|
|
|
a60c09 |
@@ -2417,13 +2420,13 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum,
|
|
|
a60c09 |
|
|
|
a60c09 |
fdict = pfont_dict(gs_rootfont(igs));
|
|
|
a60c09 |
code = dict_find_string(fdict, "CMap", &CMapDict);
|
|
|
a60c09 |
- if (code >= 0 && r_has_type(CMapDict, t_dictionary)) {
|
|
|
a60c09 |
+ if (code > 0 && r_has_type(CMapDict, t_dictionary)) {
|
|
|
a60c09 |
code = dict_find_string(CMapDict, "WMode", &WMode);
|
|
|
a60c09 |
- if (code >= 0 && r_has_type(WMode, t_integer)) {
|
|
|
a60c09 |
+ if (code > 0 && r_has_type(WMode, t_integer)) {
|
|
|
a60c09 |
wmode = WMode->value.intval;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
code = dict_find_string(CMapDict, "CMapName", &CMapName);
|
|
|
a60c09 |
- if (code >= 0 && r_has_type(CMapName, t_name)) {
|
|
|
a60c09 |
+ if (code > 0 && r_has_type(CMapName, t_name)) {
|
|
|
a60c09 |
name_string_ref(imemory, CMapName, &CMapNameStr);
|
|
|
a60c09 |
cmapnm = (char *)CMapNameStr.value.bytes;
|
|
|
a60c09 |
cmapnmlen = r_size(&CMapNameStr);
|
|
|
a60c09 |
@@ -2432,10 +2435,10 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum,
|
|
|
a60c09 |
/* We only have to lookup the char code if we're *not* using an identity ordering
|
|
|
a60c09 |
with the exception of Identity-UTF16 which is a different beast altogether */
|
|
|
a60c09 |
if (unicode_cp || (cmapnmlen > 0 && !strncmp(cmapnm, utfcmap, cmapnmlen > utfcmaplen ? utfcmaplen : cmapnmlen))
|
|
|
a60c09 |
- || (dict_find_string(pdr, "CIDSystemInfo", &CIDSystemInfo) >= 0
|
|
|
a60c09 |
+ || (dict_find_string(pdr, "CIDSystemInfo", &CIDSystemInfo) > 0
|
|
|
a60c09 |
&& r_has_type(CIDSystemInfo, t_dictionary)
|
|
|
a60c09 |
&& dict_find_string(CIDSystemInfo, "Ordering",
|
|
|
a60c09 |
- &Ordering) >= 0
|
|
|
a60c09 |
+ &Ordering) > 0
|
|
|
a60c09 |
&& r_has_type(Ordering, t_string)
|
|
|
a60c09 |
&& strncmp((const char *)Ordering->value.bytes,
|
|
|
a60c09 |
"Identity", 8) != 0)) {
|
|
|
a60c09 |
@@ -2463,7 +2466,7 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum,
|
|
|
a60c09 |
ref cc32;
|
|
|
a60c09 |
ref *gid;
|
|
|
a60c09 |
make_int(&cc32, 32);
|
|
|
a60c09 |
- if (dict_find(TT_cmap, &cc32, &gid) >= 0)
|
|
|
a60c09 |
+ if (dict_find(TT_cmap, &cc32, &gid) > 0)
|
|
|
a60c09 |
c = gid->value.intval;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
cr->char_codes[0] = c;
|
|
|
a60c09 |
@@ -2536,7 +2539,7 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum,
|
|
|
a60c09 |
if (dict_find_string(pdr, "CharStrings", &CharStrings) <= 0
|
|
|
a60c09 |
|| !r_has_type(CharStrings, t_dictionary))
|
|
|
a60c09 |
return_error(gs_error_invalidfont);
|
|
|
a60c09 |
- if ((dict_find(CharStrings, &char_name, &glyph_index) < 0)
|
|
|
a60c09 |
+ if ((dict_find(CharStrings, &char_name, &glyph_index) <= 0)
|
|
|
a60c09 |
|| r_has_type(glyph_index, t_null)) {
|
|
|
a60c09 |
#ifdef DEBUG
|
|
|
a60c09 |
ref *pvalue;
|
|
|
a60c09 |
@@ -2955,7 +2958,7 @@ zFAPIpassfont(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (dict_find_string(op, "SubfontId", &v) >= 0
|
|
|
a60c09 |
+ if (dict_find_string(op, "SubfontId", &v) > 0
|
|
|
a60c09 |
&& r_has_type(v, t_integer))
|
|
|
a60c09 |
subfont = v->value.intval;
|
|
|
a60c09 |
else
|
|
|
a60c09 |
@@ -2968,7 +2971,7 @@ zFAPIpassfont(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
/* If the font dictionary contains a FAPIPlugInReq key, the the PS world wants us
|
|
|
a60c09 |
* to try to use a specific FAPI plugin, so find it, and try it....
|
|
|
a60c09 |
*/
|
|
|
a60c09 |
- if (dict_find_string(op, "FAPIPlugInReq", &v) >= 0 && r_type(v) == t_name) {
|
|
|
a60c09 |
+ if (dict_find_string(op, "FAPIPlugInReq", &v) > 0 && r_type(v) == t_name) {
|
|
|
a60c09 |
|
|
|
a60c09 |
name_string_ref(imemory, v, &reqstr);
|
|
|
a60c09 |
|
|
|
a60c09 |
diff --git a/psi/zfcid0.c b/psi/zfcid0.c
|
|
|
a60c09 |
index 2aba09a..ba00b21 100644
|
|
|
a60c09 |
--- a/psi/zfcid0.c
|
|
|
a60c09 |
+++ b/psi/zfcid0.c
|
|
|
a60c09 |
@@ -410,13 +410,25 @@ zbuildfont9(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
* from a file, GlyphData will be an integer, and DataSource will be
|
|
|
a60c09 |
* a (reusable) stream.
|
|
|
a60c09 |
*/
|
|
|
a60c09 |
- if (code < 0 ||
|
|
|
a60c09 |
- (code = cid_font_data_param(op, &common, &GlyphDirectory)) < 0 ||
|
|
|
a60c09 |
- (code = dict_find_string(op, "FDArray", &prfda)) < 0 ||
|
|
|
a60c09 |
- (code = dict_find_string(op, "CIDFontName", &pCIDFontName)) <= 0 ||
|
|
|
a60c09 |
- (code = dict_int_param(op, "FDBytes", 0, MAX_FDBytes, -1, &FDBytes)) < 0
|
|
|
a60c09 |
- )
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ code = cid_font_data_param(op, &common, &GlyphDirectory);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ code = dict_find_string(op, "FDArray", &prfda);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ code = dict_find_string(op, "CIDFontName", &pCIDFontName);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ code = dict_int_param(op, "FDBytes", 0, MAX_FDBytes, -1, &FDBytes);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
+
|
|
|
a60c09 |
/*
|
|
|
a60c09 |
* Since build_gs_simple_font may resize the dictionary and cause
|
|
|
a60c09 |
* pointers to become invalid, save CIDFontName
|
|
|
a60c09 |
@@ -426,17 +438,24 @@ zbuildfont9(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
/* Standard CIDFont, require GlyphData and CIDMapOffset. */
|
|
|
a60c09 |
ref *pGlyphData;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if ((code = dict_find_string(op, "GlyphData", &pGlyphData)) < 0 ||
|
|
|
a60c09 |
- (code = dict_uint_param(op, "CIDMapOffset", 0, max_uint - 1,
|
|
|
a60c09 |
- max_uint, &CIDMapOffset)) < 0)
|
|
|
a60c09 |
+ code = dict_find_string(op, "GlyphData", &pGlyphData);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ code = dict_uint_param(op, "CIDMapOffset", 0, max_uint - 1, max_uint, &CIDMapOffset);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
GlyphData = *pGlyphData;
|
|
|
a60c09 |
if (r_has_type(&GlyphData, t_integer)) {
|
|
|
a60c09 |
ref *pds;
|
|
|
a60c09 |
stream *ignore_s;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if ((code = dict_find_string(op, "DataSource", &pds)) < 0)
|
|
|
a60c09 |
+ code = dict_find_string(op, "DataSource", &pds);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
check_read_file(i_ctx_p, ignore_s, pds);
|
|
|
a60c09 |
DataSource = *pds;
|
|
|
a60c09 |
} else {
|
|
|
a60c09 |
diff --git a/psi/zfcid1.c b/psi/zfcid1.c
|
|
|
a60c09 |
index ef3ece0..e3643a0 100644
|
|
|
a60c09 |
--- a/psi/zfcid1.c
|
|
|
a60c09 |
+++ b/psi/zfcid1.c
|
|
|
a60c09 |
@@ -347,11 +347,17 @@ zbuildfont11(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
ref rcidmap, ignore_gdir, file, *pfile, cfnstr, *pCIDFontName, CIDFontName, *t;
|
|
|
a60c09 |
ulong loca_glyph_pos[2][2];
|
|
|
a60c09 |
int code = cid_font_data_param(op, &common, &ignore_gdir);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
|
|
|
a60c09 |
- if (code < 0 ||
|
|
|
a60c09 |
- (code = dict_find_string(op, "CIDFontName", &pCIDFontName)) <= 0 ||
|
|
|
a60c09 |
- (code = dict_int_param(op, "MetricsCount", 0, 4, 0, &MetricsCount)) < 0
|
|
|
a60c09 |
- )
|
|
|
a60c09 |
+ code = dict_find_string(op, "CIDFontName", &pCIDFontName);
|
|
|
a60c09 |
+ if (code <= 0) {
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ }
|
|
|
a60c09 |
+ code = dict_int_param(op, "MetricsCount", 0, 4, 0, &MetricsCount);
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
/*
|
|
|
a60c09 |
* Since build_gs_simple_font may resize the dictionary and cause
|
|
|
a60c09 |
diff --git a/psi/zicc.c b/psi/zicc.c
|
|
|
a60c09 |
index ebf25fe..53bdf34 100644
|
|
|
a60c09 |
--- a/psi/zicc.c
|
|
|
a60c09 |
+++ b/psi/zicc.c
|
|
|
a60c09 |
@@ -261,6 +261,8 @@ zset_outputintent(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
code = dict_find_string(op, "N", &pnval);
|
|
|
a60c09 |
if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
ncomps = pnval->value.intval;
|
|
|
a60c09 |
|
|
|
a60c09 |
/* verify the DataSource entry. Creat profile from stream */
|
|
|
a60c09 |
@@ -491,6 +493,8 @@ znumicc_components(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
code = dict_find_string(op, "N", &pnval);
|
|
|
a60c09 |
if (code < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
ncomps = pnval->value.intval;
|
|
|
a60c09 |
/* verify the DataSource entry. Create profile from stream */
|
|
|
a60c09 |
if (dict_find_string(op, "DataSource", &pstrmval) <= 0)
|
|
|
a60c09 |
diff --git a/psi/zpdf_r6.c b/psi/zpdf_r6.c
|
|
|
a60c09 |
index bcd4907..992f316 100644
|
|
|
a60c09 |
--- a/psi/zpdf_r6.c
|
|
|
a60c09 |
+++ b/psi/zpdf_r6.c
|
|
|
a60c09 |
@@ -145,21 +145,36 @@ zcheck_r6_password(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
|
|
|
a60c09 |
code = dict_find_string(CryptDict, "O", &Oref);
|
|
|
a60c09 |
- if (code < 0 || !r_has_type(Oref, t_string)) {
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(Oref, t_string))
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
- }
|
|
|
a60c09 |
+
|
|
|
a60c09 |
code = dict_find_string(CryptDict, "OE", &OEref);
|
|
|
a60c09 |
- if (code < 0 || !r_has_type(OEref, t_string)) {
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(OEref, t_string))
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
- }
|
|
|
a60c09 |
+
|
|
|
a60c09 |
code = dict_find_string(CryptDict, "U", &Uref);
|
|
|
a60c09 |
- if (code < 0 || !r_has_type(Uref, t_string)) {
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(Uref, t_string))
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
- }
|
|
|
a60c09 |
+
|
|
|
a60c09 |
code = dict_find_string(CryptDict, "UE", &UEref);
|
|
|
a60c09 |
- if (code < 0 || !r_has_type(UEref, t_string)) {
|
|
|
a60c09 |
+ if (code < 0)
|
|
|
a60c09 |
+ return code;
|
|
|
a60c09 |
+ if (code == 0)
|
|
|
a60c09 |
+ return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(UEref, t_string))
|
|
|
a60c09 |
return_error(gs_error_typecheck);
|
|
|
a60c09 |
- }
|
|
|
a60c09 |
|
|
|
a60c09 |
pop(2);
|
|
|
a60c09 |
op = osp;
|
|
|
a60c09 |
diff --git a/psi/ztoken.c b/psi/ztoken.c
|
|
|
a60c09 |
index 519cd09..9314d97 100644
|
|
|
a60c09 |
--- a/psi/ztoken.c
|
|
|
a60c09 |
+++ b/psi/ztoken.c
|
|
|
a60c09 |
@@ -356,7 +356,7 @@ ztoken_scanner_options(const ref *upref, int old_options)
|
|
|
a60c09 |
int code = dict_find_string(upref, pnso->pname, &ppcproc);
|
|
|
a60c09 |
|
|
|
a60c09 |
/* Update the options only if the parameter has changed. */
|
|
|
a60c09 |
- if (code >= 0) {
|
|
|
a60c09 |
+ if (code > 0) {
|
|
|
a60c09 |
if (r_has_type(ppcproc, t_null))
|
|
|
a60c09 |
options &= ~pnso->option;
|
|
|
a60c09 |
else
|
|
|
a60c09 |
--
|
|
|
a60c09 |
2.17.2
|
|
|
a60c09 |
|
|
|
a60c09 |
|
|
|
a60c09 |
From 434753adbe8be5534bfb9b7d91746023e8073d16 Mon Sep 17 00:00:00 2001
|
|
|
a60c09 |
From: Ken Sharp <ken.sharp@artifex.com>
|
|
|
a60c09 |
Date: Wed, 14 Nov 2018 09:25:13 +0000
|
|
|
a60c09 |
Subject: [PATCH 2/3] Bug #700169 - unchecked type
|
|
|
a60c09 |
|
|
|
a60c09 |
Bug #700169 "Type confusion in setcolorspace"
|
|
|
a60c09 |
|
|
|
a60c09 |
In seticc() we extract "Name" from a dictionary, if it succeeds we then
|
|
|
a60c09 |
use it as a string, without checking the type to see if it is in fact
|
|
|
a60c09 |
a string.
|
|
|
a60c09 |
|
|
|
a60c09 |
Add a check on the type, and add a couple to check that 'N' is an integer
|
|
|
a60c09 |
in a few places too.
|
|
|
a60c09 |
---
|
|
|
a60c09 |
psi/zicc.c | 6 +++++-
|
|
|
a60c09 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
a60c09 |
|
|
|
a60c09 |
diff --git a/psi/zicc.c b/psi/zicc.c
|
|
|
a60c09 |
index 53bdf34..dbd2562 100644
|
|
|
a60c09 |
--- a/psi/zicc.c
|
|
|
a60c09 |
+++ b/psi/zicc.c
|
|
|
a60c09 |
@@ -76,7 +76,7 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff)
|
|
|
a60c09 |
want to have this buffer. */
|
|
|
a60c09 |
/* Check if we have the /Name entry. This is used to associate with
|
|
|
a60c09 |
specs that have enumerated types to indicate sRGB sGray etc */
|
|
|
a60c09 |
- if (dict_find_string(ICCdict, "Name", &pnameval) > 0){
|
|
|
a60c09 |
+ if (dict_find_string(ICCdict, "Name", &pnameval) > 0 && r_has_type(pnameval, t_string)){
|
|
|
a60c09 |
uint size = r_size(pnameval);
|
|
|
a60c09 |
char *str = (char *)gs_alloc_bytes(gs_gstate_memory(igs), size+1, "seticc");
|
|
|
a60c09 |
memcpy(str, (const char *)pnameval->value.bytes, size);
|
|
|
a60c09 |
@@ -263,6 +263,8 @@ zset_outputintent(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (r_type(pnval) != t_integer)
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
ncomps = pnval->value.intval;
|
|
|
a60c09 |
|
|
|
a60c09 |
/* verify the DataSource entry. Creat profile from stream */
|
|
|
a60c09 |
@@ -495,6 +497,8 @@ znumicc_components(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (r_type(pnval) != t_integer)
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
ncomps = pnval->value.intval;
|
|
|
a60c09 |
/* verify the DataSource entry. Create profile from stream */
|
|
|
a60c09 |
if (dict_find_string(op, "DataSource", &pstrmval) <= 0)
|
|
|
a60c09 |
--
|
|
|
a60c09 |
2.17.2
|
|
|
a60c09 |
|
|
|
a60c09 |
|
|
|
a60c09 |
From 9a1b3ac61761094713f44dedfce56013308a3b1d Mon Sep 17 00:00:00 2001
|
|
|
a60c09 |
From: Ken Sharp <ken.sharp@artifex.com>
|
|
|
a60c09 |
Date: Wed, 14 Nov 2018 09:31:10 +0000
|
|
|
a60c09 |
Subject: [PATCH 3/3] PS interpreter - add some type checking
|
|
|
a60c09 |
|
|
|
a60c09 |
These were 'probably' safe anyway, since they mostly treat the objects
|
|
|
a60c09 |
as integers without checking, which at least can't result in a crash.
|
|
|
a60c09 |
|
|
|
a60c09 |
Nevertheless, we ought to check.
|
|
|
a60c09 |
|
|
|
a60c09 |
The return from comparedictkeys could be wrong if one of the keys had
|
|
|
a60c09 |
a value which was not an array, it could incorrectly decide the two
|
|
|
a60c09 |
were in fact the same.
|
|
|
a60c09 |
---
|
|
|
a60c09 |
psi/zbfont.c | 15 +++++++++------
|
|
|
a60c09 |
psi/zcolor.c | 24 +++++++++++++++++++++++-
|
|
|
a60c09 |
psi/zcrd.c | 4 +++-
|
|
|
a60c09 |
psi/zfjpx.c | 2 ++
|
|
|
a60c09 |
psi/zfont.c | 3 +++
|
|
|
a60c09 |
psi/zfont0.c | 3 +++
|
|
|
a60c09 |
psi/zimage3.c | 2 ++
|
|
|
a60c09 |
psi/ztrans.c | 4 ++++
|
|
|
a60c09 |
8 files changed, 49 insertions(+), 8 deletions(-)
|
|
|
a60c09 |
|
|
|
a60c09 |
diff --git a/psi/zbfont.c b/psi/zbfont.c
|
|
|
a60c09 |
index c1d0461..5b830a2 100644
|
|
|
a60c09 |
--- a/psi/zbfont.c
|
|
|
a60c09 |
+++ b/psi/zbfont.c
|
|
|
a60c09 |
@@ -666,6 +666,9 @@ sub_font_params(gs_memory_t *mem, const ref *op, gs_matrix *pmat, gs_matrix *pom
|
|
|
a60c09 |
return_error(gs_error_invalidfont);
|
|
|
a60c09 |
if (dict_find_string(op, "OrigFont", &porigfont) <= 0)
|
|
|
a60c09 |
porigfont = NULL;
|
|
|
a60c09 |
+ if (porigfont != NULL && !r_has_type(porigfont, t_dictionary))
|
|
|
a60c09 |
+ return_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if (pomat!= NULL) {
|
|
|
a60c09 |
if (porigfont == NULL ||
|
|
|
a60c09 |
dict_find_string(porigfont, "FontMatrix", &pmatrix) <= 0 ||
|
|
|
a60c09 |
@@ -676,8 +679,8 @@ sub_font_params(gs_memory_t *mem, const ref *op, gs_matrix *pmat, gs_matrix *pom
|
|
|
a60c09 |
/* Use the FontInfo/OrigFontName key preferrentially (created by MS PSCRIPT driver) */
|
|
|
a60c09 |
if ((dict_find_string((porigfont != NULL ? porigfont : op), "FontInfo", &pfontinfo) > 0) &&
|
|
|
a60c09 |
r_has_type(pfontinfo, t_dictionary) &&
|
|
|
a60c09 |
- (dict_find_string(pfontinfo, "OrigFontName", &pfontname) > 0)) {
|
|
|
a60c09 |
- if ((dict_find_string(pfontinfo, "OrigFontStyle", &pfontstyle) > 0) &&
|
|
|
a60c09 |
+ (dict_find_string(pfontinfo, "OrigFontName", &pfontname) > 0) && (r_has_type(pfontname, t_name) || r_has_type(pfontname, t_string))) {
|
|
|
a60c09 |
+ if ((dict_find_string(pfontinfo, "OrigFontStyle", &pfontstyle) > 0) && (r_has_type(pfontname, t_name) || r_has_type(pfontname, t_string)) &&
|
|
|
a60c09 |
r_size(pfontstyle) > 0) {
|
|
|
a60c09 |
const byte *tmpStr1 = pfontname->value.const_bytes;
|
|
|
a60c09 |
const byte *tmpStr2 = pfontstyle->value.const_bytes;
|
|
|
a60c09 |
@@ -775,11 +778,11 @@ build_gs_font(i_ctx_t *i_ctx_p, os_ptr op, gs_font ** ppfont, font_type ftype,
|
|
|
a60c09 |
avm_space useglob = r_is_local(pencoding) ? avm_local : avm_global;
|
|
|
a60c09 |
|
|
|
a60c09 |
ialloc_set_space(idmemory, useglob);
|
|
|
a60c09 |
-
|
|
|
a60c09 |
+
|
|
|
a60c09 |
count = r_size(pencoding);
|
|
|
a60c09 |
if ((code = ialloc_ref_array(&penc, (r_type_attrs(pencoding) & a_readonly), count, "build_gs_font")) < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
-
|
|
|
a60c09 |
+
|
|
|
a60c09 |
while (count--) {
|
|
|
a60c09 |
ref r;
|
|
|
a60c09 |
if (array_get(imemory, pencoding, count, &r) < 0){
|
|
|
a60c09 |
@@ -790,7 +793,7 @@ build_gs_font(i_ctx_t *i_ctx_p, os_ptr op, gs_font ** ppfont, font_type ftype,
|
|
|
a60c09 |
ref_assign(&(penc.value.refs[count]), &r);
|
|
|
a60c09 |
}
|
|
|
a60c09 |
else {
|
|
|
a60c09 |
-
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if ((code = obj_cvs(imemory, &r, (byte *)buf, 32, &size, (const byte **)(&bptr))) < 0) {
|
|
|
a60c09 |
return(code);
|
|
|
a60c09 |
}
|
|
|
a60c09 |
@@ -799,7 +802,7 @@ build_gs_font(i_ctx_t *i_ctx_p, os_ptr op, gs_font ** ppfont, font_type ftype,
|
|
|
a60c09 |
ref_assign(&(penc.value.refs[count]), &r);
|
|
|
a60c09 |
}
|
|
|
a60c09 |
}
|
|
|
a60c09 |
-
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if ((code = dict_put_string(osp, "Encoding", &penc, NULL)) < 0)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
ialloc_set_space(idmemory, curglob);
|
|
|
a60c09 |
diff --git a/psi/zcolor.c b/psi/zcolor.c
|
|
|
a60c09 |
index fe81e79..b69b8f5 100644
|
|
|
a60c09 |
--- a/psi/zcolor.c
|
|
|
a60c09 |
+++ b/psi/zcolor.c
|
|
|
a60c09 |
@@ -1877,7 +1877,12 @@ static int comparedictkey(i_ctx_t * i_ctx_p, ref *CIEdict1, ref *CIEdict2, char
|
|
|
a60c09 |
if (r_type(tempref1) == t_null)
|
|
|
a60c09 |
return 1;
|
|
|
a60c09 |
|
|
|
a60c09 |
- return comparearrays(i_ctx_p, tempref1, tempref2);
|
|
|
a60c09 |
+ code = comparearrays(i_ctx_p, tempref1, tempref2);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
+ if (code > 0)
|
|
|
a60c09 |
+ return 1;
|
|
|
a60c09 |
+ else
|
|
|
a60c09 |
+ return 0;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
|
|
|
a60c09 |
static int hasharray(i_ctx_t * i_ctx_p, ref *m1, gs_md5_state_t *md5)
|
|
|
a60c09 |
@@ -5473,6 +5478,9 @@ static int seticcspace(i_ctx_t * i_ctx_p, ref *r, int *stage, int *cont, int CIE
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return gs_note_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (r_type(tempref) != t_integer)
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
components = tempref->value.intval;
|
|
|
a60c09 |
if (components > count_of(range)/2)
|
|
|
a60c09 |
return_error(gs_error_rangecheck);
|
|
|
a60c09 |
@@ -5584,6 +5592,10 @@ static int iccompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace)
|
|
|
a60c09 |
/* Need to check all the various parts */
|
|
|
a60c09 |
code1 = dict_find_string(&ICCdict1, "N", &tempref1);
|
|
|
a60c09 |
code2 = dict_find_string(&ICCdict2, "N", &tempref2);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
+ if (!r_has_type(tempref1, t_integer) || !r_has_type(tempref2, t_integer))
|
|
|
a60c09 |
+ return 0;
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if (code1 != code2)
|
|
|
a60c09 |
return 0;
|
|
|
a60c09 |
if (tempref1->value.intval != tempref2->value.intval)
|
|
|
a60c09 |
@@ -5737,6 +5749,8 @@ static int iccalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESub
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return gs_note_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(tempref, t_integer))
|
|
|
a60c09 |
+ return_error(gs_error_typecheck);
|
|
|
a60c09 |
|
|
|
a60c09 |
components = tempref->value.intval;
|
|
|
a60c09 |
|
|
|
a60c09 |
@@ -5775,6 +5789,9 @@ static int icccomponents(i_ctx_t * i_ctx_p, ref *space, int *n)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return gs_note_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(tempref, t_integer))
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
*n = tempref->value.intval;
|
|
|
a60c09 |
return 0;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
@@ -5791,6 +5808,9 @@ static int iccdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return gs_note_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(tempref, t_integer))
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
components = tempref->value.intval;
|
|
|
a60c09 |
code = dict_find_string(&ICCdict, "Range", &tempref);
|
|
|
a60c09 |
if (code > 0 && !r_has_type(tempref, t_null)) {
|
|
|
a60c09 |
@@ -5824,6 +5844,8 @@ static int iccrange(i_ctx_t * i_ctx_p, ref *space, float *ptr)
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
if (code == 0)
|
|
|
a60c09 |
return gs_note_error(gs_error_undefined);
|
|
|
a60c09 |
+ if (!r_has_type(tempref, t_integer))
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
components = tempref->value.intval;
|
|
|
a60c09 |
code = dict_find_string(&ICCdict, "Range", &tempref);
|
|
|
a60c09 |
if (code > 0 && !r_has_type(tempref, t_null)) {
|
|
|
a60c09 |
diff --git a/psi/zcrd.c b/psi/zcrd.c
|
|
|
a60c09 |
index 7993b15..d58160d 100644
|
|
|
a60c09 |
--- a/psi/zcrd.c
|
|
|
a60c09 |
+++ b/psi/zcrd.c
|
|
|
a60c09 |
@@ -231,8 +231,10 @@ zcrd1_params(os_ptr op, gs_cie_render * pcrd,
|
|
|
a60c09 |
return code;
|
|
|
a60c09 |
|
|
|
a60c09 |
if (dict_find_string(op, "RenderTable", &pRT) > 0) {
|
|
|
a60c09 |
- const ref *prte = pRT->value.const_refs;
|
|
|
a60c09 |
+ const ref *prte;
|
|
|
a60c09 |
|
|
|
a60c09 |
+ check_read_type(*pRT, t_array);
|
|
|
a60c09 |
+ prte = pRT->value.const_refs;
|
|
|
a60c09 |
/* Finish unpacking and checking the RenderTable parameter. */
|
|
|
a60c09 |
check_type_only(prte[4], t_integer);
|
|
|
a60c09 |
if (!(prte[4].value.intval == 3 || prte[4].value.intval == 4))
|
|
|
a60c09 |
diff --git a/psi/zfjpx.c b/psi/zfjpx.c
|
|
|
a60c09 |
index c622f48..db1fae2 100644
|
|
|
a60c09 |
--- a/psi/zfjpx.c
|
|
|
a60c09 |
+++ b/psi/zfjpx.c
|
|
|
a60c09 |
@@ -115,6 +115,8 @@ z_jpx_decode(i_ctx_t * i_ctx_p)
|
|
|
a60c09 |
dict_find_string(csdict, "N", &nref) > 0) {
|
|
|
a60c09 |
if_debug1m('w', imemory, "[w] JPX image has an external %"PRIpsint
|
|
|
a60c09 |
" channel colorspace\n", nref->value.intval);
|
|
|
a60c09 |
+ if (r_type(nref) != t_integer)
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
switch (nref->value.intval) {
|
|
|
a60c09 |
case 1: state.colorspace = gs_jpx_cs_gray;
|
|
|
a60c09 |
break;
|
|
|
a60c09 |
diff --git a/psi/zfont.c b/psi/zfont.c
|
|
|
a60c09 |
index 9c51792..f6c5ae1 100644
|
|
|
a60c09 |
--- a/psi/zfont.c
|
|
|
a60c09 |
+++ b/psi/zfont.c
|
|
|
a60c09 |
@@ -596,6 +596,9 @@ zfont_info(gs_font *font, const gs_point *pscale, int members,
|
|
|
a60c09 |
info->members |= FONT_INFO_FULL_NAME;
|
|
|
a60c09 |
if ((members & FONT_INFO_EMBEDDING_RIGHTS)
|
|
|
a60c09 |
&& (dict_find_string(pfontinfo, "FSType", &pvalue) > 0)) {
|
|
|
a60c09 |
+ if (r_type(pvalue) != t_integer)
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
info->EmbeddingRights = pvalue->value.intval;
|
|
|
a60c09 |
info->members |= FONT_INFO_EMBEDDING_RIGHTS;
|
|
|
a60c09 |
}
|
|
|
a60c09 |
diff --git a/psi/zfont0.c b/psi/zfont0.c
|
|
|
a60c09 |
index 4b01c20..a179d7b 100644
|
|
|
a60c09 |
--- a/psi/zfont0.c
|
|
|
a60c09 |
+++ b/psi/zfont0.c
|
|
|
a60c09 |
@@ -243,6 +243,9 @@ zbuildfont0(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
array_get(pfont->memory, &fdepvector, i, &fdep);
|
|
|
a60c09 |
/* The lookup can't fail, because of the pre-check above. */
|
|
|
a60c09 |
dict_find_string(&fdep, "FID", &pfid);
|
|
|
a60c09 |
+ if (!r_has_type(pfid, t_fontID))
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
data.FDepVector[i] = r_ptr(pfid, gs_font);
|
|
|
a60c09 |
}
|
|
|
a60c09 |
pfont->data = data;
|
|
|
a60c09 |
diff --git a/psi/zimage3.c b/psi/zimage3.c
|
|
|
a60c09 |
index 87a3dce..2beda9f 100644
|
|
|
a60c09 |
--- a/psi/zimage3.c
|
|
|
a60c09 |
+++ b/psi/zimage3.c
|
|
|
a60c09 |
@@ -53,6 +53,8 @@ zimage3(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
dict_find_string(op, "MaskDict", &pMaskDict) <= 0
|
|
|
a60c09 |
)
|
|
|
a60c09 |
return_error(gs_error_rangecheck);
|
|
|
a60c09 |
+ check_type(*pDataDict, t_dictionary);
|
|
|
a60c09 |
+ check_type(*pMaskDict, t_dictionary);
|
|
|
a60c09 |
if ((code = pixel_image_params(i_ctx_p, pDataDict,
|
|
|
a60c09 |
(gs_pixel_image_t *)&image, &ip_data,
|
|
|
a60c09 |
12, false, gs_currentcolorspace(igs))) < 0 ||
|
|
|
a60c09 |
diff --git a/psi/ztrans.c b/psi/ztrans.c
|
|
|
a60c09 |
index 64defda..0550a10 100644
|
|
|
a60c09 |
--- a/psi/ztrans.c
|
|
|
a60c09 |
+++ b/psi/ztrans.c
|
|
|
a60c09 |
@@ -417,6 +417,7 @@ zimage3x(i_ctx_t *i_ctx_p)
|
|
|
a60c09 |
gs_image3x_t_init(&image, NULL);
|
|
|
a60c09 |
if (dict_find_string(op, "DataDict", &pDataDict) <= 0)
|
|
|
a60c09 |
return_error(gs_error_rangecheck);
|
|
|
a60c09 |
+ check_type(*pDataDict, t_dictionary);
|
|
|
a60c09 |
if ((code = pixel_image_params(i_ctx_p, pDataDict,
|
|
|
a60c09 |
(gs_pixel_image_t *)&image, &ip_data,
|
|
|
a60c09 |
16, false, gs_currentcolorspace(igs))) < 0 ||
|
|
|
a60c09 |
@@ -453,6 +454,9 @@ image_params *pip_data, const char *dict_name,
|
|
|
a60c09 |
|
|
|
a60c09 |
if (dict_find_string(op, dict_name, &pMaskDict) <= 0)
|
|
|
a60c09 |
return 1;
|
|
|
a60c09 |
+ if (!r_has_type(pMaskDict, t_dictionary))
|
|
|
a60c09 |
+ return gs_note_error(gs_error_typecheck);
|
|
|
a60c09 |
+
|
|
|
a60c09 |
if ((mcode = code = data_image_params(mem, pMaskDict, &pixm->MaskDict,
|
|
|
a60c09 |
&ip_mask, false, 1, 16, false, false)) < 0 ||
|
|
|
a60c09 |
(code = dict_int_param(pMaskDict, "ImageType", 1, 1, 0, &ignored)) < 0 ||
|
|
|
a60c09 |
--
|
|
|
a60c09 |
2.17.2
|
|
|
a60c09 |
|