diff --git a/src/core/crypto.js b/src/core/crypto.js index 0abd238ca..c07e81cc3 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -449,7 +449,8 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) { - var hashData = new Uint8Array(100), i = 0, j, n; + var hashDataSize = 40 + ownerPassword.length + fileId.length; + var hashData = new Uint8Array(hashDataSize), i = 0, j, n; if (password) { n = Math.min(32, password.length); for (; i < n; ++i) diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 2f60ac8d3..e5b382e9b 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -29,6 +29,7 @@ !freeculture.pdf !pdfkit_compressed.pdf !TAMReview.pdf +!bug900822.pdf !issue918.pdf !issue1905.pdf !issue2833.pdf diff --git a/test/pdfs/bug900822.pdf b/test/pdfs/bug900822.pdf new file mode 100644 index 000000000..51aafc199 Binary files /dev/null and b/test/pdfs/bug900822.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 9eab256aa..896504610 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1439,6 +1439,12 @@ "rounds": 1, "type": "eq" }, + { "id": "bug900822", + "file": "pdfs/bug900822.pdf", + "md5": "70e2a3c5922574eeda169c955cf9d084", + "rounds": 1, + "type": "load" + }, { "id": "issue2853", "file": "pdfs/issue2853.pdf", "md5": "9f0ad95ef0b243ee8813c4eca0f7a042",