[Pkg-javascript-commits] [pdf.js] 82/109: Make `get fingerprint` slightly more robust against corrupt PDF files
David Prévot
taffit at moszumanska.debian.org
Fri Sep 25 03:04:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 5853553455b2795530985537dedd66324af4c5ee
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Mon Sep 7 17:41:13 2015 +0200
Make `get fingerprint` slightly more robust against corrupt PDF files
This patch adjusts `get fingerprint` to also check that the `/ID` entry contains (non-empty) strings, to prevent more possible failures when loading corrupt PDF files (follow-up to PR 5602).
Note that I've not actually encountered such a PDF file in the wild. However given that `stringToBytes` will assert that the input is a string, and that we'll thus fail to load a document unless `get fingerprint` succeeds, making this more robust seems like a good idea to me.
---
src/core/core.js | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/core/core.js b/src/core/core.js
index 21cb727..e188248 100644
--- a/src/core/core.js
+++ b/src/core/core.js
@@ -510,12 +510,11 @@ var PDFDocument = (function PDFDocumentClosure() {
return shadow(this, 'documentInfo', docInfo);
},
get fingerprint() {
- var xref = this.xref, idArray, hash, fileID = '';
+ var xref = this.xref, hash, fileID = '';
+ var idArray = xref.trailer.get('ID');
- if (xref.trailer.has('ID')) {
- idArray = xref.trailer.get('ID');
- }
- if (idArray && isArray(idArray) && idArray[0] !== EMPTY_FINGERPRINT) {
+ if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) &&
+ idArray[0] !== EMPTY_FINGERPRINT) {
hash = stringToBytes(idArray[0]);
} else {
if (this.stream.ensureRange) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list