[poppler] poppler/Decrypt.cc poppler/Decrypt.h

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Jun 20 14:53:41 PDT 2009


 poppler/Decrypt.cc |    8 ++++++++
 poppler/Decrypt.h  |    3 +++
 2 files changed, 11 insertions(+)

New commits:
commit bf69beeb257cfd750c6ddc8b68aeb859b36380b2
Author: David Benjamin <davidben at mit.edu>
Date:   Sat Jun 20 23:51:09 2009 +0200

    Make DecryptStream return sane values for getPos()
    
    Many streams (notably JBIG2Stream) expect wrapped streams to return correct
    values for getPos(), i.e. increments by 1 when readChar() called, etc.
    Fixes bug #19706.

diff --git a/poppler/Decrypt.cc b/poppler/Decrypt.cc
index 8719539..ca294d3 100644
--- a/poppler/Decrypt.cc
+++ b/poppler/Decrypt.cc
@@ -16,6 +16,7 @@
 // Copyright (C) 2008 Julien Rebetez <julien at fhtagn.net>
 // Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Matthias Franz <matthias at ktug.or.kr>
+// Copyright (C) 2009 David Benjamin <davidben at mit.edu>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -237,6 +238,7 @@ DecryptStream::~DecryptStream() {
 void DecryptStream::reset() {
   int i;
 
+  charactersRead = 0;
   str->reset();
   switch (algo) {
   case cryptRC4:
@@ -254,6 +256,10 @@ void DecryptStream::reset() {
   }
 }
 
+int DecryptStream::getPos() {
+  return charactersRead;
+}
+
 int DecryptStream::getChar() {
   Guchar in[16];
   int c, i;
@@ -288,6 +294,8 @@ int DecryptStream::getChar() {
     }
     break;
   }
+  if (c != EOF)
+    charactersRead++;
   return c;
 }
 
diff --git a/poppler/Decrypt.h b/poppler/Decrypt.h
index 6716f72..feb7014 100644
--- a/poppler/Decrypt.h
+++ b/poppler/Decrypt.h
@@ -14,6 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2008 Julien Rebetez <julien at fhtagn.net>
+// Copyright (C) 2009 David Benjamin <davidben at mit.edu>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -90,6 +91,7 @@ public:
   virtual void reset();
   virtual int getChar();
   virtual int lookChar();
+  virtual int getPos();
   virtual GBool isBinary(GBool last);
   virtual Stream *getUndecodedStream() { return this; }
 
@@ -98,6 +100,7 @@ private:
   CryptAlgorithm algo;
   int objKeyLength;
   Guchar objKey[16 + 9];
+  int charactersRead; // so that getPos() can be correct
 
   union {
     DecryptRC4State rc4;


More information about the poppler mailing list