diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-03 13:41:07 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-04 00:31:22 +0200 |
commit | 92b692466f7a4dbf4e51e6a77713c029a3e18ab1 (patch) | |
tree | ba139d7b9c290bfc2a83c2719cf0ce86cf27ad36 /libqpdf/Pl_AES_PDF.cc | |
parent | b20f0519224b0c089f78730fb20291cc2d539979 (diff) | |
download | qpdf-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.cc | 11 |
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; |