Blame SOURCES/ghostscript-cve-2018-16511.patch

8812f8
From: Chris Liddell <chris.liddell@artifex.com>
8812f8
Date: Tue, 21 Aug 2018 19:36:52 +0000 (+0100)
8812f8
Subject: Bug 699659: Don't just assume an object is a t_(a)struct
8812f8
8812f8
Bug 699659: Don't just assume an object is a t_(a)struct
8812f8
8812f8
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=0edd3d6c634a577db261615a9dc2719bca7f6e01
8812f8
---
8812f8
8812f8
diff -up a/psi/ztype.c.cve-2018-16511 b/psi/ztype.c
8812f8
--- a/psi/ztype.c.cve-2018-16511	2018-11-14 09:52:09.491518742 +0100
8812f8
+++ b/psi/ztype.c	2018-11-14 10:14:02.238279799 +0100
8812f8
@@ -76,6 +76,7 @@ ztype(i_ctx_t *i_ctx_p)
8812f8
         /* Must be either a stack underflow or a t_[a]struct. */
8812f8
         check_op(2);
8812f8
         {                       /* Get the type name from the structure. */
8812f8
+            if ((r_has_type(&op[-1], t_struct) || r_has_type(&op[-1], t_astruct)) && op[-1].value.pstruct != 0x00) {
8812f8
             const char *sname =
8812f8
                 gs_struct_type_name_string(gs_object_type(imemory,
8812f8
                                                           op[-1].value.pstruct));
8812f8
@@ -84,6 +85,8 @@ ztype(i_ctx_t *i_ctx_p)
8812f8
 
8812f8
             if (code < 0)
8812f8
                 return code;
8812f8
+            } else
8812f8
+                return_error(gs_error_stackunderflow);
8812f8
         }
8812f8
         r_set_attrs(op - 1, a_executable);
8812f8
     } else {