[poppler] Branch 'xpdf303merge' - 3 commits - poppler/JBIG2Stream.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Sep 5 10:37:45 PDT 2011


 poppler/JBIG2Stream.cc |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

New commits:
commit 23066e8e8309babd61ade9f50ef7d82c9e275055
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 19:41:16 2011 +0200

    xpdf303: More EOF detection

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 78bf92d..a0450a9 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -3500,7 +3500,9 @@ void JBIG2Stream::readEndOfStripeSeg(Guint length) {
 
   // skip the segment
   for (i = 0; i < length; ++i) {
-    curStr->getChar();
+    if (curStr->getChar() == EOF) {
+      break;
+    }
   }
 }
 
@@ -3509,7 +3511,9 @@ void JBIG2Stream::readProfilesSeg(Guint length) {
 
   // skip the segment
   for (i = 0; i < length; ++i) {
-    curStr->getChar();
+    if (curStr->getChar() == EOF) {
+      break;
+    }
   }
 }
 
@@ -3582,7 +3586,9 @@ void JBIG2Stream::readExtensionSeg(Guint length) {
 
   // skip the segment
   for (i = 0; i < length; ++i) {
-    curStr->getChar();
+    if (curStr->getChar() == EOF) {
+      break;
+    }
   }
 }
 
commit bc6eded798d6e5dc7a58f88afbe4ab2904698db5
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 19:38:29 2011 +0200

    xpdf303: Comment++

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 43a5921..78bf92d 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -2299,6 +2299,8 @@ JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
     s = sFirst;
 
     // read the instances
+    // (this loop test is here to avoid an infinite loop with damaged
+    // JBIG2 streams where the normal loop exit doesn't get triggered)
     while (inst < numInstances) {
 
       // T value
commit adb98856a745340b4ffb34ffd2ed701600cfc82f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 19:38:02 2011 +0200

    xpdf303: Exit loop in case of EOF

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index f538dc6..43a5921 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -1309,7 +1309,9 @@ void JBIG2Stream::readSegments() {
       refFlags = (refFlags << 24) | (c1 << 16) | (c2 << 8) | c3;
       nRefSegs = refFlags & 0x1fffffff;
       for (i = 0; i < (nRefSegs + 9) >> 3; ++i) {
-	c1 = curStr->getChar();
+	if ((c1 = curStr->getChar()) == EOF) {
+	  goto eofError1;
+	}
       }
     }
 
@@ -1511,7 +1513,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
   Guint symHeight, symWidth, totalWidth, x, symID;
   int dh, dw, refAggNum, refDX, refDY, bmSize;
   GBool ex;
-  int run, cnt;
+  int run, cnt, c;
   Guint i, j, k;
   Guchar *p;
 
@@ -1821,7 +1823,10 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
 	bmSize = symHeight * ((totalWidth + 7) >> 3);
 	p = collBitmap->getDataPtr();
 	for (k = 0; k < (Guint)bmSize; ++k) {
-	  *p++ = curStr->getChar();
+	  if ((c = curStr->getChar()) == EOF) {
+	    break;
+	  }
+	  *p++ = (Guchar)c;
 	}
       } else {
 	collBitmap = readGenericBitmap(gTrue, totalWidth, symHeight,


More information about the poppler mailing list