From: Chris Liddell <chris.liddell@artifex.com>
Date: Mon, 12 Jun 2017 13:15:17 +0100
Subject: Bug 698026: bounds check zone pointers in Ins_IP()
Origin: http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=98f6da60b9d463c617e631fc254cf6d66f2e8e3c
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2017-9612
Bug-Debian: https://bugs.debian.org/869916
Bug: https://bugs.ghostscript.com/show_bug.cgi?id=698026

---
 base/ttinterp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/base/ttinterp.c b/base/ttinterp.c
index f6a6d95fe..e7c9d68f7 100644
--- a/base/ttinterp.c
+++ b/base/ttinterp.c
@@ -4129,7 +4129,9 @@ static int nInstrCount=0;
     Int         point;
     (void)args;
 
-    if ( CUR.top < CUR.GS.loop )
+    if ( CUR.top < CUR.GS.loop ||
+         BOUNDS(CUR.GS.rp1, CUR.zp0.n_points) ||
+         BOUNDS(CUR.GS.rp2, CUR.zp1.n_points))
     {
       CUR.error = TT_Err_Invalid_Reference;
       return;
-- 
2.14.2

