Re: 2.99.1: new beta / almost release candidate

[email protected] (Frank Küster)
Newsgroups gmane.comp.tex.tetex.beta
Message-ID <[email protected]>
Tobias Burnus <[email protected]> schrieb:

> Hello,
>
> Thomas Esser wrote:
>
>>Well, shortly after 2.99.0, we now see this 2.99.1 release. [...]
>>Changes in the src area:
>>
> I've a question: PDFTeX uses the XPDF library and there had been
> recently security problems detected (CAN-2004-0888, CAN-2004-0889).

And I sent a patch for teTeX 2.0.2 which has not yet reached me again
through the list. I fear I might have sent a wrong patch that still
contained code that would be optimised away by compilers. Here's the
correct one.

Bye, Frank
-- 
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer
tetex-bin_2.0.2-22-sec.patch (text/x-patch, 3 KB)
--- tetex-bin-2.0.2-CVS/libs/xpdf/xpdf/Catalog.cc.orig	Wed Oct 27 13:57:48 2004
+++ tetex-bin-2.0.2-CVS/libs/xpdf/xpdf/Catalog.cc	Wed Oct 27 14:15:00 2004
@@ -22,6 +22,7 @@
 #include "Error.h"
 #include "Link.h"
 #include "Catalog.h"
+#include <limits.h>
 
 //------------------------------------------------------------------------
 // Catalog
@@ -63,6 +64,12 @@
   }
   pagesSize = numPages0 = obj.getInt();
   obj.free();
+  if (pagesSize >= INT_MAX/sizeof(Page *) ||
+      pagesSize >= INT_MAX/sizeof(Ref)) {
+    error(-1, "Invalid 'pagesSize'");
+    ok = gFalse;
+    return;
+  }
   pages = (Page **)gmalloc(pagesSize * sizeof(Page *));
   pageRefs = (Ref *)gmalloc(pagesSize * sizeof(Ref));
   for (i = 0; i < pagesSize; ++i) {
@@ -190,6 +197,11 @@
       }
       if (start >= pagesSize) {
 	pagesSize += 32;
+        if (pagesSize >= INT_MAX/sizeof(Page *) ||
+            pagesSize >= INT_MAX/sizeof(Ref)) {
+          error(-1, "Invalid 'pagesSize' parameter.");
+          goto err3;
+        }
 	pages = (Page **)grealloc(pages, pagesSize * sizeof(Page *));
 	pageRefs = (Ref *)grealloc(pageRefs, pagesSize * sizeof(Ref));
 	for (j = pagesSize - 32; j < pagesSize; ++j) {
--- tetex-bin-2.0.2-CVS/libs/xpdf/xpdf/XRef.cc.orig	Wed Oct 27 13:57:51 2004
+++ tetex-bin-2.0.2-CVS/libs/xpdf/xpdf/XRef.cc	Wed Oct 27 14:14:45 2004
@@ -28,6 +28,7 @@
 #include "Error.h"
 #include "ErrorCodes.h"
 #include "XRef.h"
+#include <limits.h>
 
 //------------------------------------------------------------------------
 
@@ -76,6 +77,12 @@
 
   // trailer is ok - read the xref table
   } else {
+    if (size >= INT_MAX/sizeof(XRefEntry)) {
+      error(-1, "Invalid 'size' inside xref table.");
+      ok = gFalse;
+      errCode = errDamaged;
+      return;
+    }
     entries = (XRefEntry *)gmalloc(size * sizeof(XRefEntry));
     for (i = 0; i < size; ++i) {
       entries[i].offset = 0xffffffff;
@@ -267,6 +274,10 @@
     // table size
     if (first + n > size) {
       newSize = size + 256;
+      if (newSize >= INT_MAX/sizeof(XRefEntry)) {
+        error(-1, "Invalid 'newSize'");
+        goto err2;
+      }
       entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
       for (i = size; i < newSize; ++i) {
 	entries[i].offset = 0xffffffff;
@@ -410,6 +421,10 @@
 	    if (!strncmp(p, "obj", 3)) {
 	      if (num >= size) {
 		newSize = (num + 1 + 255) & ~255;
+	        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) {
@@ -431,6 +446,11 @@
     } else if (!strncmp(p, "endstream", 9)) {
       if (streamEndsLen == streamEndsSize) {
 	streamEndsSize += 64;
+        if (streamEndsSize >= INT_MAX/sizeof(int)) {
+          error(-1, "Invalid 'endstream' parameter.");
+          return gFalse;
+        }
+
 	streamEnds = (Guint *)grealloc(streamEnds,
 				       streamEndsSize * sizeof(int));
       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.