Commit bf69beeb authored by David Benjamin's avatar David Benjamin Committed by Albert Astals Cid

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.
parent 5ee4ff2a
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Matthias Franz <matthias@ktug.or.kr> // Copyright (C) 2009 Matthias Franz <matthias@ktug.or.kr>
// Copyright (C) 2009 David Benjamin <davidben@mit.edu>
// //
// To see a description of the changes please see the Changelog file that // 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 // came with your tarball or type make ChangeLog if you are building from git
...@@ -237,6 +238,7 @@ DecryptStream::~DecryptStream() { ...@@ -237,6 +238,7 @@ DecryptStream::~DecryptStream() {
void DecryptStream::reset() { void DecryptStream::reset() {
int i; int i;
charactersRead = 0;
str->reset(); str->reset();
switch (algo) { switch (algo) {
case cryptRC4: case cryptRC4:
...@@ -254,6 +256,10 @@ void DecryptStream::reset() { ...@@ -254,6 +256,10 @@ void DecryptStream::reset() {
} }
} }
int DecryptStream::getPos() {
return charactersRead;
}
int DecryptStream::getChar() { int DecryptStream::getChar() {
Guchar in[16]; Guchar in[16];
int c, i; int c, i;
...@@ -288,6 +294,8 @@ int DecryptStream::getChar() { ...@@ -288,6 +294,8 @@ int DecryptStream::getChar() {
} }
break; break;
} }
if (c != EOF)
charactersRead++;
return c; return c;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
// under GPL version 2 or later // under GPL version 2 or later
// //
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 David Benjamin <davidben@mit.edu>
// //
// To see a description of the changes please see the Changelog file that // 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 // came with your tarball or type make ChangeLog if you are building from git
...@@ -90,6 +91,7 @@ public: ...@@ -90,6 +91,7 @@ public:
virtual void reset(); virtual void reset();
virtual int getChar(); virtual int getChar();
virtual int lookChar(); virtual int lookChar();
virtual int getPos();
virtual GBool isBinary(GBool last); virtual GBool isBinary(GBool last);
virtual Stream *getUndecodedStream() { return this; } virtual Stream *getUndecodedStream() { return this; }
...@@ -98,6 +100,7 @@ private: ...@@ -98,6 +100,7 @@ private:
CryptAlgorithm algo; CryptAlgorithm algo;
int objKeyLength; int objKeyLength;
Guchar objKey[16 + 9]; Guchar objKey[16 + 9];
int charactersRead; // so that getPos() can be correct
union { union {
DecryptRC4State rc4; DecryptRC4State rc4;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment