76f8c5
commit f966b8766d40b2c912e69a1e17ef8cc4bd52be95
76f8c5
Author: Carlos Garcia Campos <carlosgc@gnome.org>
76f8c5
Date:   Tue Oct 21 16:42:27 2014 +0200
76f8c5
76f8c5
    fofi: Fix a crash when parsing an invalid font due to a integer overflow
76f8c5
    
76f8c5
    This fixes a crash rendering trust_metrics.f2495.f0.pdf.
76f8c5
76f8c5
diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc
76f8c5
index 8fa10a0..2245184 100644
76f8c5
--- a/fofi/FoFiType1.cc
76f8c5
+++ b/fofi/FoFiType1.cc
76f8c5
@@ -263,7 +263,7 @@ void FoFiType1::parse() {
76f8c5
 	    } else {
76f8c5
 	      break;
76f8c5
 	    }
76f8c5
-	    for (; *p >= '0' && *p < '0' + base; ++p) {
76f8c5
+	    for (; *p >= '0' && *p < '0' + base && code < INT_MAX / (base + (*p - '0')); ++p) {
76f8c5
 	      code = code * base + (*p - '0');
76f8c5
 	    }
76f8c5
 	    for (; *p == ' ' || *p == '\t'; ++p) ;