Fix arcfour initialization and encoding; png prediction fix
This commit is contained in:
parent
490571f7f9
commit
4326a1d5bf
14
pdf.js
14
pdf.js
@ -716,7 +716,7 @@ var PredictorStream = (function() {
|
||||
var rawBytes = this.stream.getBytes(rowBytes);
|
||||
|
||||
var bufferLength = this.bufferLength;
|
||||
var buffer = this.ensureBuffer(bufferLength + pixBytes);
|
||||
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
||||
|
||||
var currentRow = buffer.subarray(bufferLength, bufferLength + rowBytes);
|
||||
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
||||
@ -833,7 +833,7 @@ var DecryptStream = (function() {
|
||||
var buffer = this.ensureBuffer(bufferLength + n);
|
||||
for (i = 0; i < n; i++)
|
||||
buffer[bufferLength++] = chunk[i];
|
||||
this.bufferLength = n;
|
||||
this.bufferLength = bufferLength;
|
||||
this.eof = n < chunkSize;
|
||||
};
|
||||
|
||||
@ -1468,7 +1468,7 @@ var Parser = (function() {
|
||||
|
||||
stream = stream.makeSubStream(pos, length, dict);
|
||||
if (cipherTransform)
|
||||
stream = cipherTransform.createString(stream);
|
||||
stream = cipherTransform.createStream(stream);
|
||||
stream = this.filter(stream, dict, length);
|
||||
stream.parameters = dict;
|
||||
return stream;
|
||||
@ -1802,7 +1802,11 @@ var XRef = (function() {
|
||||
}
|
||||
error("bad XRef entry");
|
||||
}
|
||||
e = parser.getObj(this.encrypt);
|
||||
if (this.encrypt) {
|
||||
e = parser.getObj(this.encrypt.createCipherTransform(num, gen));
|
||||
} else {
|
||||
e = parser.getObj();
|
||||
}
|
||||
// Don't cache streams since they are mutable.
|
||||
if (!IsStream(e))
|
||||
this.cache[num] = e;
|
||||
@ -2629,7 +2633,7 @@ var CanvasGraphics = (function() {
|
||||
}
|
||||
}
|
||||
} else if (cmd == "Tf") { // eagerly collect all fonts
|
||||
var fontRes; // = resources.get("Font");
|
||||
var fontRes = resources.get("Font");
|
||||
if (fontRes) {
|
||||
fontRes = xref.fetchIfRef(fontRes);
|
||||
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
||||
|
11
security.js
11
security.js
@ -5,7 +5,6 @@
|
||||
|
||||
var ARCFourCipher = (function() {
|
||||
function constructor(key) {
|
||||
var key = this.key;
|
||||
this.a = 0;
|
||||
this.b = 0;
|
||||
var s = new Uint8Array(256);
|
||||
@ -133,13 +132,13 @@ var CipherTransform = (function() {
|
||||
}
|
||||
constructor.prototype = {
|
||||
createStream: function (stream) {
|
||||
var cipher = new streamCipherConstructor();
|
||||
var cipher = new this.streamCipherConstructor();
|
||||
return new DecryptStream(stream, function(data) {
|
||||
return cipher.encryptBlock(data);
|
||||
});
|
||||
},
|
||||
decryptString: function(s) {
|
||||
var cipher = new stringCipherConstructor();
|
||||
var cipher = new this.stringCipherConstructor();
|
||||
var data = string2bytes(s);
|
||||
data = cipher.encryptBlock(data);
|
||||
return bytes2string(data);
|
||||
@ -240,9 +239,9 @@ var CipherTransformFactory = (function() {
|
||||
constructor.prototype = {
|
||||
createCipherTransform: function(num, gen) {
|
||||
var encryptionKey = this.encryptionKey;
|
||||
var key = new Uint8Array(encryptionKey.length + 5), i, j, n;
|
||||
for (j = 0, n = encryptionKey.length; j < n; ++j)
|
||||
key[j] = encryptionKey[j];
|
||||
var key = new Uint8Array(encryptionKey.length + 5), i, n;
|
||||
for (i = 0, n = encryptionKey.length; i < n; ++i)
|
||||
key[i] = encryptionKey[i];
|
||||
key[i++] = num & 0xFF;
|
||||
key[i++] = (num >> 8) & 0xFF;
|
||||
key[i++] = (num >> 16) & 0xFF;
|
||||
|
Loading…
Reference in New Issue
Block a user