summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2012-03-01 22:51:49 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-03-06 16:10:22 +0100
commit126417304a0286c8998a5856b3fdae92357a785d (patch)
treedbc9c70e86e6b8ecd354389f2d220638d0d24d8f /pdf
parentc5c6aa47e4fbc0323c36065a6f8acaaed609f852 (diff)
downloadmupdf-126417304a0286c8998a5856b3fdae92357a785d.tar.xz
Guess encryption revision from the version if missing.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_crypt.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index c99e696c..cbd495d2 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -158,10 +158,20 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
obj = pdf_dict_gets(dict, "R");
if (pdf_is_int(obj))
crypt->r = pdf_to_int(obj);
+ else if (crypt->v <= 4)
+ {
+ fz_warn(ctx, "encryption dictionary missing revision value, guessing...");
+ if (crypt->v < 2)
+ crypt->r = 2;
+ else if (crypt->v == 2 || crypt->v == 3)
+ crypt->r = 3;
+ else if (crypt->v == 4)
+ crypt->r = 4;
+ }
else
{
pdf_free_crypt(ctx, crypt);
- fz_throw(ctx, "encryption dictionary missing revision value");
+ fz_throw(ctx, "encryption dictionary missing version and revision value");
}
obj = pdf_dict_gets(dict, "O");