diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-07-18 15:50:05 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-07-18 15:50:05 +0200 |
commit | 8657c6f00489b5c26fc0c00f2fc91c5682acbe95 (patch) | |
tree | c3052b8767ce0bbf4df8da747e5e383fda826b78 | |
parent | 8ea2f8441dec01f8ca685127c3e61713b397a428 (diff) | |
download | qpdf-8657c6f00489b5c26fc0c00f2fc91c5682acbe95.tar.zst |
Prevent seeking before beginning of BufferInputSource
-rw-r--r-- | libqpdf/QPDF.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 4a764964..1a8a689d 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -231,6 +231,10 @@ QPDF::BufferInputSource::~BufferInputSource() qpdf_offset_t QPDF::BufferInputSource::findAndSkipNextEOL() { + if (this->cur_offset < 0) + { + throw std::logic_error("INTERNAL ERROR: BufferInputSource offset < 0"); + } qpdf_offset_t end_pos = (qpdf_offset_t) this->buf->getSize(); if (this->cur_offset >= end_pos) { @@ -301,6 +305,12 @@ QPDF::BufferInputSource::seek(qpdf_offset_t offset, int whence) "INTERNAL ERROR: invalid argument to BufferInputSource::seek"); break; } + + if (this->cur_offset < 0) + { + throw std::runtime_error( + this->description + ": seek before beginning of buffer"); + } } void @@ -312,6 +322,10 @@ QPDF::BufferInputSource::rewind() size_t QPDF::BufferInputSource::read(char* buffer, size_t length) { + if (this->cur_offset < 0) + { + throw std::logic_error("INTERNAL ERROR: BufferInputSource offset < 0"); + } qpdf_offset_t end_pos = (qpdf_offset_t) this->buf->getSize(); if (this->cur_offset >= end_pos) { |