diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2020-12-15 16:46:56 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2020-12-15 16:46:56 +0000 |
commit | e1dfb92cc593cd27ed593ffcc3a79711b7504563 (patch) | |
tree | cce31d30b47ba67f793814dbc7540279a3bbc671 | |
parent | 4d91c6ad3e76e19f36d23a50dce253fbbc7d0560 (diff) | |
download | ghostpdl-e1dfb92cc593cd27ed593ffcc3a79711b7504563.tar.gz |
PDF interpreter - handle indirect objects in Encrypt dictionary
Bug #703272 "This PDF files converts to tiff using the oitsample program, but the font turns from English to what looks like chinese"
The Encrypt dictionary and the subsidiary StdCF dictionary are stored
as indirect objects (presumably in order to make the file larger). The
decryption code wasn't expecting that.
Add code to dereference the objects. While we're here, add code to check
the types of the objects and ensure they are correct, and throw an
error if they are not.
-rw-r--r-- | Resource/Init/pdf_sec.ps | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/Resource/Init/pdf_sec.ps b/Resource/Init/pdf_sec.ps index b6f2bfce5..b4361b8da 100644 --- a/Resource/Init/pdf_sec.ps +++ b/Resource/Init/pdf_sec.ps @@ -481,15 +481,33 @@ systemdict /check_r6_password .forceundef % Even if StmF and StrF are Identity, if the StdCF is missing AuthEvent % or it is DocOpen, we require the password. Check for that. 1 index /CF .knownget { - /StdCF .knownget { - /AuthEvent .knownget { - /DocOpen eq - or + oforce dup type /dicttype eq { + /StdCF .knownget { + oforce dup type /dicttype eq { + /AuthEvent .knownget { + oforce dup type /nametype eq { + /DocOpen eq + or + }{ + ( **** Error: AuthEvent has wrong type.\n) pdfformaterror + ( Cannot decrypt PDF file.\n) pdfformaterror + /pdf_process_Encrypt cvx /invalidfileaccess signalerror + } ifelse + } { + pop true % no AuthEvent, default is DocOpen, require password + } ifelse + }{ + ( **** Error: StdCF has wrong type.\n) pdfformaterror + ( Cannot decrypt PDF file.\n) pdfformaterror + /pdf_process_Encrypt cvx /invalidfileaccess signalerror + } ifelse } { - pop true % no AuthEvent, default is DocOpen, require password + pop true % no StdCF, require password } ifelse - } { - pop true % no StdCF, require password + }{ + ( **** Error: CF has wrong type.\n) pdfformaterror + ( Cannot decrypt PDF file.\n) pdfformaterror + /pdf_process_Encrypt cvx /invalidfileaccess signalerror } ifelse } { pop true % no CF, require password |