mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-31 02:48:31 +00:00
don't place restrictions on length of /ID strings
git-svn-id: svn+q:///qpdf/trunk@961 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
349c80c895
commit
fc8f93053d
@ -24,7 +24,6 @@ static char const padding_string[] = {
|
||||
};
|
||||
|
||||
static unsigned int const O_key_bytes = sizeof(MD5::Digest);
|
||||
static unsigned int const id_bytes = 16;
|
||||
static unsigned int const key_bytes = 32;
|
||||
|
||||
void
|
||||
@ -145,7 +144,7 @@ QPDF::compute_encryption_key(
|
||||
pbytes[2] = (char) ((data.P >> 16) & 0xff);
|
||||
pbytes[3] = (char) ((data.P >> 24) & 0xff);
|
||||
md5.encodeDataIncrementally(pbytes, 4);
|
||||
md5.encodeDataIncrementally(data.id1.c_str(), id_bytes);
|
||||
md5.encodeDataIncrementally(data.id1.c_str(), data.id1.length());
|
||||
if ((data.R >= 4) && (! data.encrypt_metadata))
|
||||
{
|
||||
char bytes[4];
|
||||
@ -343,14 +342,6 @@ QPDF::initializeEncryption()
|
||||
}
|
||||
|
||||
std::string id1 = id_obj.getArrayItem(0).getStringValue();
|
||||
if (id1.length() != id_bytes)
|
||||
{
|
||||
throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
|
||||
"trailer", this->file.getLastOffset(),
|
||||
"first /ID string in trailer dictionary has "
|
||||
"incorrect length");
|
||||
}
|
||||
|
||||
QPDFObjectHandle encryption_dict = this->trailer.getKey("/Encrypt");
|
||||
if (! encryption_dict.isDictionary())
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ flush_tiff_cache();
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Miscellaneous Tests ---");
|
||||
$n_tests += 18;
|
||||
$n_tests += 22;
|
||||
|
||||
$td->runtest("qpdf version",
|
||||
{$td->COMMAND => "qpdf --version"},
|
||||
@ -134,6 +134,24 @@ $td->runtest("check output",
|
||||
{$td->FILE => "a.qdf"},
|
||||
{$td->FILE => "unreferenced-indirect-scalar.out"});
|
||||
|
||||
# Encrypt files whose /ID strings are other than 32 bytes long (bug
|
||||
# 2991412).
|
||||
foreach my $file (qw(short-id long-id))
|
||||
{
|
||||
$td->runtest("encrypt $file.pdf",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --encrypt '' pass 40 -- $file.pdf a.pdf"},
|
||||
{$td->STRING => "",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
$td->runtest("check $file.pdf",
|
||||
{$td->COMMAND => "qpdf --check a.pdf"},
|
||||
{$td->FILE => "$file-check.out",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
}
|
||||
|
||||
# Min/Force version
|
||||
$td->runtest("set min version",
|
||||
{$td->COMMAND => "qpdf --min-version=1.6 good1.pdf a.pdf"},
|
||||
|
17
qpdf/qtest/qpdf/long-id-check.out
Normal file
17
qpdf/qtest/qpdf/long-id-check.out
Normal file
@ -0,0 +1,17 @@
|
||||
checking a.pdf
|
||||
PDF Version: 1.3
|
||||
R = 2
|
||||
P = -4
|
||||
User password =
|
||||
extract for accessibility: allowed
|
||||
extract for any purpose: allowed
|
||||
print low resolution: allowed
|
||||
print high resolution: allowed
|
||||
modify document assembly: allowed
|
||||
modify forms: allowed
|
||||
modify annotations: allowed
|
||||
modify other: allowed
|
||||
modify anything: allowed
|
||||
File is not linearized
|
||||
No syntax or stream encoding errors found; the file may still contain
|
||||
errors that qpdf cannot detect
|
80
qpdf/qtest/qpdf/long-id.pdf
Normal file
80
qpdf/qtest/qpdf/long-id.pdf
Normal file
@ -0,0 +1,80 @@
|
||||
%PDF-1.3
|
||||
1 0 obj
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Pages 2 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/Kids [
|
||||
3 0 R
|
||||
]
|
||||
/Count 1
|
||||
>>
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 2 0 R
|
||||
/MediaBox [0 0 612 792]
|
||||
/Contents 4 0 R
|
||||
/Resources <<
|
||||
/ProcSet 5 0 R
|
||||
/Font <<
|
||||
/F1 6 0 R
|
||||
>>
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<<
|
||||
/Length 44
|
||||
>>
|
||||
stream
|
||||
BT
|
||||
/F1 24 Tf
|
||||
72 720 Td
|
||||
(Potato) Tj
|
||||
ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
[
|
||||
/PDF
|
||||
/Text
|
||||
]
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/Name /F1
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 7
|
||||
0000000000 65535 f
|
||||
0000000009 00000 n
|
||||
0000000063 00000 n
|
||||
0000000135 00000 n
|
||||
0000000307 00000 n
|
||||
0000000403 00000 n
|
||||
0000000438 00000 n
|
||||
trailer <<
|
||||
/Size 7
|
||||
/Root 1 0 R
|
||||
/ID [<443A32303130303432333131333433382B303227303027> <443A32303130303432333131333433382B303227303027>]
|
||||
>>
|
||||
startxref
|
||||
556
|
||||
%%EOF
|
17
qpdf/qtest/qpdf/short-id-check.out
Normal file
17
qpdf/qtest/qpdf/short-id-check.out
Normal file
@ -0,0 +1,17 @@
|
||||
checking a.pdf
|
||||
PDF Version: 1.3
|
||||
R = 2
|
||||
P = -4
|
||||
User password =
|
||||
extract for accessibility: allowed
|
||||
extract for any purpose: allowed
|
||||
print low resolution: allowed
|
||||
print high resolution: allowed
|
||||
modify document assembly: allowed
|
||||
modify forms: allowed
|
||||
modify annotations: allowed
|
||||
modify other: allowed
|
||||
modify anything: allowed
|
||||
File is not linearized
|
||||
No syntax or stream encoding errors found; the file may still contain
|
||||
errors that qpdf cannot detect
|
80
qpdf/qtest/qpdf/short-id.pdf
Normal file
80
qpdf/qtest/qpdf/short-id.pdf
Normal file
@ -0,0 +1,80 @@
|
||||
%PDF-1.3
|
||||
1 0 obj
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Pages 2 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/Kids [
|
||||
3 0 R
|
||||
]
|
||||
/Count 1
|
||||
>>
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 2 0 R
|
||||
/MediaBox [0 0 612 792]
|
||||
/Contents 4 0 R
|
||||
/Resources <<
|
||||
/ProcSet 5 0 R
|
||||
/Font <<
|
||||
/F1 6 0 R
|
||||
>>
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<<
|
||||
/Length 44
|
||||
>>
|
||||
stream
|
||||
BT
|
||||
/F1 24 Tf
|
||||
72 720 Td
|
||||
(Potato) Tj
|
||||
ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
[
|
||||
/PDF
|
||||
/Text
|
||||
]
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/Name /F1
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 7
|
||||
0000000000 65535 f
|
||||
0000000009 00000 n
|
||||
0000000063 00000 n
|
||||
0000000135 00000 n
|
||||
0000000307 00000 n
|
||||
0000000403 00000 n
|
||||
0000000438 00000 n
|
||||
trailer <<
|
||||
/Size 7
|
||||
/Root 1 0 R
|
||||
/ID [<443A32303130303432333131> <443A32303130303432333131>]
|
||||
>>
|
||||
startxref
|
||||
556
|
||||
%%EOF
|
Loading…
x
Reference in New Issue
Block a user