summaryrefslogtreecommitdiff
path: root/pdf/pdf_sec.c
Commit message (Collapse)AuthorAgeFilesLines
* GhostPDF - set the default for the key length when /V is 1Ken Sharp2023-04-251-5/+9
| | | | | | | | | | | | | Bug #706668 "regression: new PDF engine can't handle a broken PDF file, falsely reports password protected" Although the file is damaged (in fact it appears to be 2 PDF files, concatenated) that's not the problem. The second file is the one which we process, and that file is encrypted. We simply were not setting the encryption key length for Revision 3 and we were only reading the actual key /Length if /V is present and has the value 2 or 3. This is basically because PDF encryption is a mess, and simply an oversight. Fix it here.
* Update postal address in file headersChris Liddell2023-04-041-3/+3
|
* GhostPDF - Don't assume R3 security handler has 128 bitsKen Sharp2022-06-041-24/+46
| | | | | | | | | | The revision 3 encryption code may have more than 40 bits, but it need not have more. Also the V entry in the encryption dictionary is optional for PDF versions before 2.0. Rework the code to cater for both these cases.
* GhostPDF Ignore Encrypt /Length for version 1 algorithmKen Sharp2022-05-251-9/+10
| | | | | | | | | The version 1 (/V 1) algorithm has a fixed key length of 40 bits, there should not be a /Length key in the dictionary for this encryption but if there is it should be 40. Ignore /Length altogether for version 1 encryption algorithm to prevent confusion with version 2.
* GhostPDF - Fix Encrypted Metadata files with V <= 3Ken Sharp2022-05-171-0/+1
| | | | | | | | | | | Bug #705307 "Output is an empty PDF" An oversight, when We have an EncryptMetadata key in the Encrypt dictionary, we end up with code = 1. If the V (Version) of the handler is then <= 3 we return that, which incorrectly indicats the file is not encrypted. Just reset the value.
* PDFI: Use TRUE/FALSE/NULL objects as 'fast' objects.Robin Watts2022-05-051-3/+3
| | | | No allocation/deallocation required.
* Fix compiler warningKen Sharp2022-03-091-1/+1
| | | | | Use parentheses to make a test more explicitly obvious, hopefull this will satisfy gcc.
* OSS-fuzz #44983 - Apply limits to decryption /LengthKen Sharp2022-02-241-8/+16
| | | | | | | | | | | | | We were using the /Length value supplied in the Encrypt dictionary even for encryption types where that is not valid. This commit fixes the KeyLen value for those encryption types for which it is not a variable (most of them), checks the minimum/maximum and multiple of 8 for the on really variable type, and flags warnings if the /Length is supplied for an inappropriate filter. It's possible we will see a load of files encrypted with V 3-6 which supply a /Length where they technically shouldn't, and will raise a warning. We might want to not do that in future if it proves irksome.
* GhostPDF - handle encrypted file with both StmF and StrF /IdentityKen Sharp2022-02-171-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | The file /tests_private/pdf/PDF_1.7_ATS/AC8ZD1CC_Save.pdf is an encrypted file, using security handler version 4, PDF 1.5, where the Encrypt dictionary has both the StmF and StrF filters set to /Identity. This means the file is, in effect, not encrypted. Though technically it is possible for a compressed object stream to specify a different filter. We were unable to create an object key because both filters were Identity, leading to us failing to open the file. This commit will continue in that case, and also will short-circuit a little of the setup which is not required if the filter being used is Identity for either streams or strings. Previously the code worked correctly, it just went through some hoops that we don't actually need to do, so this is (very) slightly more efficient. Ghostscript gives a warning about this case, but I've chosen not to here as technically the file is entirely valid from that point of view (it has many other problems). If anyone ever comlains we can add the warning easily enough.
* OS-fuzz #42718 - don't use ctx->Trailer directly.Ken Sharp2021-12-201-4/+19
| | | | | | | | | | | If we repair the file (which can happen any time) it is possible that ctx->Trailer might be replaced. If we are using it, and have not taken a separate reference, then it could vanish while we are using it. Since this isn't the first time this has come up, review and amend all places using ctx->Trailer to use a temporary reference instead. Add comments in each location and add comments to the definition in ghostpdf.h to try and avoid a repetition.
* OSS-fuzz #42455 - handle missing entries in Encryption dictKen Sharp2021-12-181-0/+4
| | | | | I'd forgotten to cater for the 'not found' case when checking the encryption dictionary contents.
* Fix various lgtm constant comparison issues.Robin Watts2021-09-211-45/+40
|
* Commit pdfi to master.Robin Watts2021-08-121-0/+1418
This is a commit of the pdfi branch to master, eliminating the traditional merge step. The full history of the pdfi branch can be seen in the repo, and that branch is effectively frozen from this point onwards. This commit actually differs from pdfi in a small number of whitespace changes (trailing spaces etc).