Blob Blame History Raw
From: Ken Sharp <ken.sharp@artifex.com>
Date: Wed, 14 Nov 2018 09:27:00 +0000 (+0000)
Subject: Bug #700168 - add a type check

Bug #700168 - add a type check

Bug #700168 "Type confusion in JBIG2Decode"

The code was assuming that .jbig2globalctx was a structure allocated
by the graphics library, without checking.

Add a check to see that it is a structure and that its the correct
type of structure.

https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=ef252e7dc214bcbd9a2539216aab9202848602bb
---

diff -up ghostscript-9.07/psi/zfjbig2.c.cve-2018-19477 ghostscript-9.07/psi/zfjbig2.c
--- ghostscript-9.07/psi/zfjbig2.c.cve-2018-19477	2019-01-15 10:36:23.973538520 +0100
+++ ghostscript-9.07/psi/zfjbig2.c	2019-01-15 10:37:16.897897568 +0100
@@ -72,6 +72,8 @@ z_jbig2decode(i_ctx_t * i_ctx_p)
     if (r_has_type(op, t_dictionary)) {
         check_dict_read(*op);
         if ( dict_find_string(op, ".jbig2globalctx", &sop) > 0) {
+            if (!r_is_struct(sop) || !r_has_stype(sop, imemory, st_jbig2_global_data_t))
+                return_error(gs_error_typecheck);
             gref = r_ptr(sop, s_jbig2_global_data_t);
             s_jbig2decode_set_global_data((stream_state*)&state, gref);
         }