aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_AES_PDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-03 13:41:07 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-04 00:31:22 +0200
commit92b692466f7a4dbf4e51e6a77713c029a3e18ab1 (patch)
treeba139d7b9c290bfc2a83c2719cf0ce86cf27ad36 /libqpdf/Pl_AES_PDF.cc
parentb20f0519224b0c089f78730fb20291cc2d539979 (diff)
downloadqpdf-92b692466f7a4dbf4e51e6a77713c029a3e18ab1.tar.zst
Remove remaining incorrect assert calls from implementation
Diffstat (limited to 'libqpdf/Pl_AES_PDF.cc')
-rw-r--r--libqpdf/Pl_AES_PDF.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc
index 80cd8534..dc281fae 100644
--- a/libqpdf/Pl_AES_PDF.cc
+++ b/libqpdf/Pl_AES_PDF.cc
@@ -3,7 +3,6 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QPDFCryptoProvider.hh>
#include <qpdf/QUtil.hh>
-#include <assert.h>
#include <cstring>
#include <stdexcept>
#include <stdlib.h>
@@ -115,7 +114,10 @@ Pl_AES_PDF::finish()
// 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);
+ if (this->offset >= this->buf_size) {
+ throw std::logic_error("buffer overflow in AES encryption"
+ " pipeline");
+ }
std::memset(
this->inbuf + this->offset, 0, this->buf_size - this->offset);
this->offset = this->buf_size;
@@ -147,7 +149,10 @@ Pl_AES_PDF::initializeVector()
void
Pl_AES_PDF::flush(bool strip_padding)
{
- assert(this->offset == this->buf_size);
+ if (this->offset != this->buf_size) {
+ throw std::logic_error(
+ "AES pipeline: flush called when buffer was not full");
+ }
if (first) {
first = false;