Commit 95114fe256290ecd251c7b4b7b1d494873c743e6
1 parent
75b55b7a
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
Showing
1 changed file
with
9 additions
and
4 deletions
libqpdf/Pl_AES_PDF.cc
| @@ -102,10 +102,15 @@ Pl_AES_PDF::finish() | @@ -102,10 +102,15 @@ Pl_AES_PDF::finish() | ||
| 102 | { | 102 | { |
| 103 | if (this->offset != this->buf_size) | 103 | if (this->offset != this->buf_size) |
| 104 | { | 104 | { |
| 105 | - throw std::runtime_error( | ||
| 106 | - "aes encrypted stream length was not a multiple of " + | ||
| 107 | - QUtil::int_to_string(this->buf_size) + " bytes (offset = " + | ||
| 108 | - QUtil::int_to_string(this->offset) + ")"); | 105 | + // This is never supposed to happen as the output is |
| 106 | + // always supposed to be padded. However, we have | ||
| 107 | + // encountered files for which the output is not a | ||
| 108 | + // multiple of the block size. In this case, pad with | ||
| 109 | + // zeroes and hope for the best. | ||
| 110 | + assert(this->buf_size > this->offset); | ||
| 111 | + std::memset(this->inbuf + this->offset, 0, | ||
| 112 | + this->buf_size - this->offset); | ||
| 113 | + this->offset = this->buf_size; | ||
| 109 | } | 114 | } |
| 110 | flush(true); | 115 | flush(true); |
| 111 | } | 116 | } |