aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_AES_PDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2010-03-27 14:17:31 +0100
committerJay Berkenbilt <ejb@ql.org>2010-03-27 14:17:31 +0100
commit95114fe256290ecd251c7b4b7b1d494873c743e6 (patch)
tree519bcf5ce384e73943a21ef7f5c738fefa0c007c /libqpdf/Pl_AES_PDF.cc
parent75b55b7aad4fab2def877c33ae9649166dea3efe (diff)
downloadqpdf-95114fe256290ecd251c7b4b7b1d494873c743e6.tar.zst
pad and hope for the best of AES input buffer is not a multiple of 16
git-svn-id: svn+q:///qpdf/trunk@944 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/Pl_AES_PDF.cc')
-rw-r--r--libqpdf/Pl_AES_PDF.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc
index d9754981..a43d7e69 100644
--- a/libqpdf/Pl_AES_PDF.cc
+++ b/libqpdf/Pl_AES_PDF.cc
@@ -102,10 +102,15 @@ Pl_AES_PDF::finish()
{
if (this->offset != this->buf_size)
{
- throw std::runtime_error(
- "aes encrypted stream length was not a multiple of " +
- QUtil::int_to_string(this->buf_size) + " bytes (offset = " +
- QUtil::int_to_string(this->offset) + ")");
+ // This is never supposed to happen as the output is
+ // always supposed to be padded. However, we have
+ // encountered files for which the output is not a
+ // multiple of the block size. In this case, pad with
+ // zeroes and hope for the best.
+ assert(this->buf_size > this->offset);
+ std::memset(this->inbuf + this->offset, 0,
+ this->buf_size - this->offset);
+ this->offset = this->buf_size;
}
flush(true);
}