summaryrefslogtreecommitdiff
path: root/print/teTeX3-bin/patches/patch-ak
blob: 63a38848477a5323478668a6448445e0f8690f8c (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$NetBSD: patch-ak,v 1.1.1.1 2005/03/31 22:09:18 hubertf Exp $

--- libs/xpdf/xpdf/XRef.cc.orig	2005-01-19 12:09:57.000000000 +0000
+++ libs/xpdf/xpdf/XRef.cc
@@ -28,6 +28,7 @@
 #include "Error.h"
 #include "ErrorCodes.h"
 #include "XRef.h"
+#include <limits.h>
 
 //------------------------------------------------------------------------
 
@@ -388,6 +389,10 @@ GBool XRef::readXRefTable(Parser *parser
       if (newSize < 0) {
 	goto err1;
       }
+      if (newSize >= INT_MAX/sizeof(XRefEntry)) {
+        error(-1, "Invalid 'newSize'");
+	goto err1;
+      }
       entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
       for (i = size; i < newSize; ++i) {
 	entries[i].offset = 0xffffffff;
@@ -493,6 +498,10 @@ GBool XRef::readXRefStream(Stream *xrefS
     goto err1;
   }
   if (newSize > size) {
+    if (newSize >= INT_MAX/sizeof(XRefEntry)) {
+      error(-1, "Invalid 'newSize'");
+      goto err1;
+    }
     entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
     for (i = size; i < newSize; ++i) {
       entries[i].offset = 0xffffffff;
@@ -583,6 +592,10 @@ GBool XRef::readXRefStreamSection(Stream
     if (newSize < 0) {
       return gFalse;
     }
+    if (newSize >= INT_MAX / sizeof(XRefEntry)) {
+      error(-1, "Invalid 'obj' parameters.");
+      return gFalse;
+    }
     entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
     for (i = size; i < newSize; ++i) {
       entries[i].offset = 0xffffffff;
@@ -718,6 +731,10 @@ GBool XRef::constructXRef() {
 		    error(-1, "Bad object number");
 		    return gFalse;
 		  }
+	          if (newSize >= INT_MAX / sizeof(XRefEntry)) {
+	            error(-1, "Invalid 'newSize' parameters.");
+	            return gFalse;
+	          }
 		  entries = (XRefEntry *)
 		      grealloc(entries, newSize * sizeof(XRefEntry));
 		  for (i = size; i < newSize; ++i) {
@@ -741,6 +758,10 @@ GBool XRef::constructXRef() {
     } else if (!strncmp(p, "endstream", 9)) {
       if (streamEndsLen == streamEndsSize) {
 	streamEndsSize += 64;
+  	if (streamEndsSize >= INT_MAX/sizeof(int)) {
+  	  error(-1, "Invalid 'streamEndSize' parameter.");
+  	  return gFalse;
+  	}
 	streamEnds = (Guint *)grealloc(streamEnds,
 				       streamEndsSize * sizeof(int));
       }