From c086b1d44133b48b1114460dc5d9e1358cf9380f Mon Sep 17 00:00:00 2001 From: samalloing Date: Tue, 26 Apr 2022 14:46:22 +0200 Subject: [PATCH 1/2] Unhandeld exception when Encrypt is a Dictionary and not an indirect object --- .../harvard/hul/ois/jhove/module/PdfModule.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java index 0dcb770d8..ca6e93ef8 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java @@ -473,7 +473,7 @@ public class PdfModule extends ModuleBase { protected Map _pageSeqMap; protected PdfIndirectObj _docCatDictRef; - protected PdfIndirectObj _encryptDictRef; + protected PdfObject _encryptDictRef; protected PdfIndirectObj _docInfoDictRef; protected PdfIndirectObj _pagesDictRef; @@ -1362,9 +1362,16 @@ protected boolean parseTrailer(RepInfo info, boolean prevOnly) throw new PdfInvalidException(MessageConstants.PDF_HUL_75, // PDF-HUL-75 _parser.getOffset()); } - _encryptDictRef = (PdfIndirectObj) _trailerDict - .get(DICT_KEY_ENCRYPT); // This is at least v. 1.1 - _encrypted = (_encryptDictRef != null); + + PdfObject encryptDict = _trailerDict.get(DICT_KEY_ENCRYPT); + if(encryptDict != null && encryptDict instanceof PdfIndirectObj) + { + _encryptDictRef = (PdfIndirectObj) encryptDict; // This is at least v. 1.1 + _encrypted = (_encryptDictRef != null); + } else if (encryptDict != null && encryptDict instanceof PdfDictionary) { + _encryptDictRef = (PdfDictionary) encryptDict; + _encrypted = (_encryptDictRef != null); + } PdfObject infoObj = _trailerDict.get(DICT_KEY_INFO); if (infoObj != null && !(infoObj instanceof PdfIndirectObj)) { From ef8f1e66ad102686df37ab8fc3c3c5876ca23a4b Mon Sep 17 00:00:00 2001 From: samalloing Date: Tue, 26 Apr 2022 16:29:07 +0200 Subject: [PATCH 2/2] Unhandled exception when Size is not an Integer --- .../java/edu/harvard/hul/ois/jhove/module/PdfModule.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java index ca6e93ef8..a46de07d7 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java @@ -1341,9 +1341,13 @@ protected boolean parseTrailer(RepInfo info, boolean prevOnly) _numObjects = -1; if (obj instanceof PdfSimpleObject) { token = ((PdfSimpleObject) obj).getToken(); - if (token instanceof Numeric) + if (token instanceof Numeric) { _numObjects = ((Numeric) token).getIntegerValue(); - _xref = new long[_numObjects]; + _xref = new long[_numObjects]; + } else { + throw new PdfInvalidException(MessageConstants.PDF_HUL_73, // PDF-HUL-73 + _parser.getOffset()); + } } if (_numObjects < 0) { throw new PdfInvalidException(MessageConstants.PDF_HUL_73, // PDF-HUL-73