[poppler] poppler/poppler: JBIG2Stream.cc, 1.3, 1.4 Stream.cc, 1.9, 1.10

Kristian Høgsberg krh at freedesktop.org
Wed Jan 11 08:53:00 PST 2006


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv18989/poppler

Modified Files:
	JBIG2Stream.cc Stream.cc 
Log Message:
2006-01-11  Kristian Høgsberg  <krh at redhat.com>

        * poppler/JBIG2Stream.cc:
        * poppler/Stream.cc: Merge patch to fix CVE-2005-3624,
        CVE-2005-3625 and CVE-2005-3627 issues.




Index: JBIG2Stream.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/JBIG2Stream.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- JBIG2Stream.cc	31 Aug 2005 09:51:41 -0000	1.3
+++ JBIG2Stream.cc	11 Jan 2006 16:52:58 -0000	1.4
@@ -13,6 +13,7 @@
 #endif
 
 #include <stdlib.h>
+#include <limits.h>
 #include "goo/GooList.h"
 #include "Error.h"
 #include "JArithmeticDecoder.h"
@@ -681,6 +682,12 @@
   w = wA;
   h = hA;
   line = (wA + 7) >> 3;
+
+  if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+    error(-1, "invalid width/height");
+    data = NULL;
+    return;
+  }
   // need to allocate one extra guard byte for use in combine()
   data = (Guchar *)gmalloc(h * line + 1);
   data[h * line] = 0;
@@ -692,6 +699,12 @@
   w = bitmap->w;
   h = bitmap->h;
   line = bitmap->line;
+
+  if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+    error(-1, "invalid width/height");
+    data = NULL;
+    return;
+  }
   // need to allocate one extra guard byte for use in combine()
   data = (Guchar *)gmalloc(h * line + 1);
   memcpy(data, bitmap->data, h * line);
@@ -720,7 +733,10 @@
 }
 
 void JBIG2Bitmap::expand(int newH, Guint pixel) {
-  if (newH <= h) {
+  if (newH <= h || line <= 0 || newH >= (INT_MAX - 1) / line) {
+    error(-1, "invalid width/height");
+    gfree(data);
+    data = NULL;
     return;
   }
   // need to allocate one extra guard byte for use in combine()
@@ -2305,6 +2321,15 @@
     error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
     return;
   }
+  if (gridH == 0 || gridW >= INT_MAX / gridH) {
+    error(getPos(), "Bad size in JBIG2 halftone segment");
+    return;
+  }
+  if (w == 0 || h >= INT_MAX / w) {
+     error(getPos(), "Bad size in JBIG2 bitmap segment");
+    return;
+  }
+
   patternDict = (JBIG2PatternDict *)seg;
   bpp = 0;
   i = 1;
@@ -2936,6 +2961,11 @@
   JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2;
   int x, y, pix;
 
+  if (w < 0 || h <= 0 || w >= INT_MAX / h) {
+    error(-1, "invalid width/height");
+    return NULL;
+  }
+
   bitmap = new JBIG2Bitmap(0, w, h);
   bitmap->clearToZero();
 

Index: Stream.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Stream.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Stream.cc	21 Dec 2005 22:09:47 -0000	1.9
+++ Stream.cc	11 Jan 2006 16:52:58 -0000	1.10
@@ -2930,7 +2930,8 @@
   width = read16();
   numComps = str->getChar();
   if (numComps <= 0 || numComps > 4) {
-    error(getPos(), "Bad number of components in DCT stream", prec);
+    numComps = 0;
+    error(getPos(), "Bad number of components in DCT stream");
     return gFalse;
   }
   if (prec != 8) {
@@ -2982,6 +2983,7 @@
   length = read16() - 2;
   scanInfo.numComps = str->getChar();
   if (scanInfo.numComps <= 0 || scanInfo.numComps > 4) {
+    scanInfo.numComps = 0;
     error(getPos(), "Bad number of components in DCT stream");
     return gFalse;
   }
@@ -3193,9 +3195,9 @@
     do {
       c = str->getChar();
     } while (c != 0xff && c != EOF);
-    do {
+    while (c == 0xff) {
       c = str->getChar();
-    } while (c == 0xff);
+    }
   } while (c == 0x00);
   return c;
 }



More information about the poppler mailing list