summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2010-09-24 21:10:08 +0200
committerJay Berkenbilt <ejb@ql.org>2010-09-24 21:10:08 +0200
commitce8b1ba6a5a5650d90571f5c39855af341dfad47 (patch)
tree8604c8d4a96f67fb44e830a6177a9f931c27fc30 /libqpdf/QPDF_encryption.cc
parentaa035961b38b6f01090e6f6a2ee4c9b9fb5041e8 (diff)
downloadqpdf-ce8b1ba6a5a5650d90571f5c39855af341dfad47.tar.zst
convert file to a PointerHolder<InputSource> so it could be either a file or a buffer; also fix a bug in BufferInputSource::seek
git-svn-id: svn+q:///qpdf/trunk@1030 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc51
1 files changed, 26 insertions, 25 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index 8ac0ec90..51691399 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -336,8 +336,8 @@ QPDF::initializeEncryption()
(id_obj.getArrayNItems() == 2) &&
id_obj.getArrayItem(0).isString()))
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- "trailer", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ "trailer", this->file->getLastOffset(),
"invalid /ID in trailer dictionary");
}
@@ -345,23 +345,23 @@ QPDF::initializeEncryption()
QPDFObjectHandle encryption_dict = this->trailer.getKey("/Encrypt");
if (! encryption_dict.isDictionary())
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
this->last_object_description,
- this->file.getLastOffset(),
+ this->file->getLastOffset(),
"/Encrypt in trailer dictionary is not a dictionary");
}
if (! (encryption_dict.getKey("/Filter").isName() &&
(encryption_dict.getKey("/Filter").getName() == "/Standard")))
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"unsupported encryption filter");
}
if (! encryption_dict.getKey("/SubFilter").isNull())
{
- warn(QPDFExc(qpdf_e_unsupported, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ warn(QPDFExc(qpdf_e_unsupported, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"file uses encryption SubFilters,"
" which qpdf does not support"));
}
@@ -372,8 +372,8 @@ QPDF::initializeEncryption()
encryption_dict.getKey("/U").isString() &&
encryption_dict.getKey("/P").isInteger()))
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"some encryption dictionary parameters are missing "
"or the wrong type");
}
@@ -387,8 +387,8 @@ QPDF::initializeEncryption()
if (! (((R == 2) || (R == 3) || (R == 4)) &&
((V == 1) || (V == 2) || (V == 4))))
{
- throw QPDFExc(qpdf_e_unsupported, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_unsupported, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"Unsupported /R or /V in encryption dictionary");
}
@@ -396,8 +396,8 @@ QPDF::initializeEncryption()
if (! ((O.length() == key_bytes) && (U.length() == key_bytes)))
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"incorrect length for /O and/or /P in "
"encryption dictionary");
}
@@ -408,8 +408,8 @@ QPDF::initializeEncryption()
Length = encryption_dict.getKey("/Length").getIntValue();
if ((Length % 8) || (Length < 40) || (Length > 128))
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"invalid /Length value in encryption dictionary");
}
}
@@ -472,8 +472,8 @@ QPDF::initializeEncryption()
}
if (this->cf_file != this->cf_stream)
{
- throw QPDFExc(qpdf_e_unsupported, this->file.getName(),
- "encryption dictionary", this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_unsupported, this->file->getName(),
+ "encryption dictionary", this->file->getLastOffset(),
"This document has embedded files that are"
" encrypted differently from the rest of the file."
" qpdf does not presently support this due to"
@@ -494,7 +494,7 @@ QPDF::initializeEncryption()
}
else
{
- throw QPDFExc(qpdf_e_password, this->file.getName(),
+ throw QPDFExc(qpdf_e_password, this->file->getName(),
"", 0, "invalid password");
}
@@ -545,9 +545,9 @@ QPDF::decryptString(std::string& str, int objid, int generation)
break;
default:
- warn(QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
+ warn(QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
this->last_object_description,
- this->file.getLastOffset(),
+ this->file->getLastOffset(),
"unknown encryption filter for strings"
" (check /StrF in /Encrypt dictionary);"
" strings may be decrypted improperly"));
@@ -595,8 +595,9 @@ QPDF::decryptString(std::string& str, int objid, int generation)
}
catch (std::runtime_error& e)
{
- throw QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
- this->last_object_description, this->file.getLastOffset(),
+ throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ this->last_object_description,
+ this->file->getLastOffset(),
"error decrypting string for object " +
QUtil::int_to_string(objid) + " " +
QUtil::int_to_string(generation) + ": " + e.what());
@@ -669,9 +670,9 @@ QPDF::decryptStream(Pipeline*& pipeline, int objid, int generation,
default:
// filter local to this stream.
- warn(QPDFExc(qpdf_e_damaged_pdf, this->file.getName(),
+ warn(QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
this->last_object_description,
- this->file.getLastOffset(),
+ this->file->getLastOffset(),
"unknown encryption filter for streams"
" (check " + method_source + ");"
" streams may be decrypted improperly"));