76f8c5
From 60b4fe65bc9dc9b82bbadf0be2e3781be796a13d Mon Sep 17 00:00:00 2001
76f8c5
From: Albert Astals Cid <aacid@kde.org>
76f8c5
Date: Tue, 1 May 2018 02:46:17 +0200
76f8c5
Subject: FoFiType1C::cvtGlyph: Fix infinite recursion on malformed documents
76f8c5
76f8c5
Bugs #104942, #103238
76f8c5
---
76f8c5
 fofi/FoFiType1C.cc | 7 ++++---
76f8c5
 1 file changed, 4 insertions(+), 3 deletions(-)
76f8c5
76f8c5
diff --git a/fofi/FoFiType1C.cc b/fofi/FoFiType1C.cc
76f8c5
index 03e7799..b14561f 100644
76f8c5
--- a/fofi/FoFiType1C.cc
76f8c5
+++ b/fofi/FoFiType1C.cc
76f8c5
@@ -13,7 +13,7 @@
76f8c5
 // All changes made under the Poppler project to this file are licensed
76f8c5
 // under GPL version 2 or later
76f8c5
 //
76f8c5
-// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
76f8c5
+// Copyright (C) 2009, 2010, 2017, 2018 Albert Astals Cid <aacid@kde.org>
76f8c5
 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
76f8c5
 //
76f8c5
 // To see a description of the changes please see the Changelog file that
76f8c5
@@ -32,6 +32,7 @@
76f8c5
 #include <math.h>
76f8c5
 #include "goo/gmem.h"
76f8c5
 #include "goo/gstrtod.h"
76f8c5
+#include "goo/GooLikely.h"
76f8c5
 #include "goo/GooString.h"
76f8c5
 #include "FoFiEncodings.h"
76f8c5
 #include "FoFiType1C.h"
76f8c5
@@ -1361,7 +1362,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf,
76f8c5
 	  --nOps;
76f8c5
 	  ok = gTrue;
76f8c5
 	  getIndexVal(subrIdx, k, &val, &ok;;
76f8c5
-	  if (ok) {
76f8c5
+	  if (likely(ok && val.pos != offset)) {
76f8c5
 	    cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse);
76f8c5
 	  }
76f8c5
 	} else {
76f8c5
@@ -1596,7 +1597,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf,
76f8c5
 	  --nOps;
76f8c5
 	  ok = gTrue;
76f8c5
 	  getIndexVal(&gsubrIdx, k, &val, &ok;;
76f8c5
-	  if (ok) {
76f8c5
+	  if (likely(ok && val.pos != offset)) {
76f8c5
 	    cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse);
76f8c5
 	  }
76f8c5
 	} else {
76f8c5
-- 
76f8c5
cgit v1.1
76f8c5