commit 6f9f259034de956ad7db69151755250e98727a1d Author: David Benjamin Date: Sat Jun 20 17:05:49 2009 -0400 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..c1a80b8 100644 --- a/poppler/Decrypt.cc +++ b/poppler/Decrypt.cc @@ -237,6 +237,7 @@ DecryptStream::~DecryptStream() { void DecryptStream::reset() { int i; + charactersRead = 0; str->reset(); switch (algo) { case cryptRC4: @@ -254,6 +255,10 @@ void DecryptStream::reset() { } } +int DecryptStream::getPos() { + return charactersRead; +} + int DecryptStream::getChar() { Guchar in[16]; int c, i; @@ -288,6 +293,8 @@ int DecryptStream::getChar() { } break; } + if (c != EOF) + charactersRead++; return c; } diff --git a/poppler/Decrypt.h b/poppler/Decrypt.h index 6716f72..d4693df 100644 --- a/poppler/Decrypt.h +++ b/poppler/Decrypt.h @@ -90,6 +90,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 +99,7 @@ private: CryptAlgorithm algo; int objKeyLength; Guchar objKey[16 + 9]; + int charactersRead; // so that getPos() can be correct union { DecryptRC4State rc4;