gnu: ghostscript: Fix CVE-2013-5653 and CVE-2016-{7976,7978,7979,8602}.
[jackhill/guix/guix.git] / gnu / packages / patches / ghostscript-CVE-2016-7979.patch
1 The following patch was adapted for GNU Ghostscript
2 by Mark H Weaver <mhw@netris.org> based on:
3
4 http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=875a0095f37626a721c7ff57d606a0f95af03913
5
6 From 875a0095f37626a721c7ff57d606a0f95af03913 Mon Sep 17 00:00:00 2001
7 From: Ken Sharp <ken.sharp@artifex.com>
8 Date: Wed, 5 Oct 2016 10:10:58 +0100
9 Subject: [PATCH] DSC parser - validate parameters
10
11 Bug #697190 ".initialize_dsc_parser doesn't validate the parameter is a dict type before using it."
12
13 Regardless of any security implications, its simply wrong for a PostScript
14 operator not to validate its parameter(s).
15
16 No differences expected.
17 ---
18 psi/zdscpars.c | 13 +++++++++----
19 1 file changed, 9 insertions(+), 4 deletions(-)
20
21 diff --git a/psi/zdscpars.c b/psi/zdscpars.c
22 index c05e154..9b4b605 100644
23 --- a/psi/zdscpars.c
24 +++ b/psi/zdscpars.c
25 @@ -150,11 +150,16 @@ zinitialize_dsc_parser(i_ctx_t *i_ctx_p)
26 ref local_ref;
27 int code;
28 os_ptr const op = osp;
29 - dict * const pdict = op->value.pdict;
30 - gs_memory_t * const mem = (gs_memory_t *)dict_memory(pdict);
31 - dsc_data_t * const data =
32 - gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t, "DSC parser init");
33 + dict *pdict;
34 + gs_memory_t *mem;
35 + dsc_data_t *data;
36
37 + check_read_type(*op, t_dictionary);
38 +
39 + pdict = op->value.pdict;
40 + mem = (gs_memory_t *)dict_memory(pdict);
41 +
42 + data = gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t, "DSC parser init");
43 if (!data)
44 return_error(e_VMerror);
45 data->document_level = 0;
46 --
47 2.9.1
48