summaryrefslogtreecommitdiff
path: root/print/xpdf/patches/patch-bd
blob: 7367979684253b9d4f88bf4443c77fd0bcbfaba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$NetBSD: patch-bd,v 1.1 2010/10/13 21:29:43 tez Exp $

Fix for CVE-2010-3704
from http://www.openbsd.org/cgi-bin/cvsweb/ports/textproc/xpdf/patches/patch-fofi_FoFiType1_cc?rev=1.1

--- fofi/FoFiType1.cc.orig	2010-10-13 14:51:21.493696100 -0500
+++ fofi/FoFiType1.cc	2010-10-13 14:58:20.655403000 -0500
@@ -18,6 +18,14 @@
 #include "FoFiEncodings.h"
 #include "FoFiType1.h"
 
+#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+# define likely(x)      __builtin_expect((x), 1)
+# define unlikely(x)    __builtin_expect((x), 0)
+#else
+# define likely(x)      (x)
+# define unlikely(x)    (x)
+#endif
+
 //------------------------------------------------------------------------
 // FoFiType1
 //------------------------------------------------------------------------
@@ -224,7 +232,7 @@
 		code = code * 8 + (*p2 - '0');
 	      }
 	    }
-	    if (code < 256) {
+	    if (likely(code < 256 && code >= 0)) {
 	      for (p = p2; *p == ' ' || *p == '\t'; ++p) ;
 	      if (*p == '/') {
 		++p;