From 126417304a0286c8998a5856b3fdae92357a785d Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 1 Mar 2012 22:51:49 +0100 Subject: Guess encryption revision from the version if missing. --- pdf/pdf_crypt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'pdf') 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"); -- cgit v1.2.3