summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-crypt.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-04-19 15:55:28 +0200
committerRobin Watts <robin.watts@artifex.com>2016-04-22 17:26:48 +0100
commit4584bb1fbd3208e516a6f17b36c3b861903529f7 (patch)
treeec9e0d1a2bda151559c8db76f927b21248644eca /source/pdf/pdf-crypt.c
parentf9f144849ca9611dd46e6cbb27b9f1100371e455 (diff)
downloadmupdf-4584bb1fbd3208e516a6f17b36c3b861903529f7.tar.xz
pdf: Handle implicit identity crypt filters
Fixes http://bugs.ghostscript.com/show_bug.cgi?id=696687
Diffstat (limited to 'source/pdf/pdf-crypt.c')
-rw-r--r--source/pdf/pdf-crypt.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index 49d1904b..f98daa2e 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -302,27 +302,29 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, pdf_crypt *crypt,
}
dict = pdf_dict_get(ctx, crypt->cf, name);
- if (!pdf_is_dict(ctx, dict))
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot parse crypt filter (%d %d R)", pdf_to_num(ctx, crypt->cf), pdf_to_gen(ctx, crypt->cf));
-
- obj = pdf_dict_get(ctx, dict, PDF_NAME_CFM);
- if (pdf_is_name(ctx, obj))
+ if (pdf_is_dict(ctx, dict))
{
- if (pdf_name_eq(ctx, PDF_NAME_None, obj))
- cf->method = PDF_CRYPT_NONE;
- else if (pdf_name_eq(ctx, PDF_NAME_V2, obj))
- cf->method = PDF_CRYPT_RC4;
- else if (pdf_name_eq(ctx, PDF_NAME_AESV2, obj))
- cf->method = PDF_CRYPT_AESV2;
- else if (pdf_name_eq(ctx, PDF_NAME_AESV3, obj))
- cf->method = PDF_CRYPT_AESV3;
- else
- fz_warn(ctx, "unknown encryption method: %s", pdf_to_name(ctx, obj));
- }
+ obj = pdf_dict_get(ctx, dict, PDF_NAME_CFM);
+ if (pdf_is_name(ctx, obj))
+ {
+ if (pdf_name_eq(ctx, PDF_NAME_None, obj))
+ cf->method = PDF_CRYPT_NONE;
+ else if (pdf_name_eq(ctx, PDF_NAME_V2, obj))
+ cf->method = PDF_CRYPT_RC4;
+ else if (pdf_name_eq(ctx, PDF_NAME_AESV2, obj))
+ cf->method = PDF_CRYPT_AESV2;
+ else if (pdf_name_eq(ctx, PDF_NAME_AESV3, obj))
+ cf->method = PDF_CRYPT_AESV3;
+ else
+ fz_warn(ctx, "unknown encryption method: %s", pdf_to_name(ctx, obj));
+ }
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Length);
- if (pdf_is_int(ctx, obj))
- cf->length = pdf_to_int(ctx, obj);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME_Length);
+ if (pdf_is_int(ctx, obj))
+ cf->length = pdf_to_int(ctx, obj);
+ }
+ else if (!is_identity)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot parse crypt filter (%d %d R)", pdf_to_num(ctx, crypt->cf), pdf_to_gen(ctx, crypt->cf));
/* the length for crypt filters is supposed to be in bytes not bits */
if (cf->length < 40)