aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-07-28 00:18:18 +0200
committerJay Berkenbilt <ejb@ql.org>2017-07-28 00:43:07 +0200
commita4fd4b91c6f7f732536bd113cd7b4e23a08ca599 (patch)
tree3e617732b8feff546373150d69afe9ac493a230f /libqpdf
parent40f00122b811ca5c8788856f5baf4e5e088926eb (diff)
downloadqpdf-a4fd4b91c6f7f732536bd113cd7b4e23a08ca599.tar.zst
Convert stream filtering errors to warnings
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF_Stream.cc33
-rw-r--r--libqpdf/qpdf-c.cc2
-rw-r--r--libqpdf/qpdf/QPDF_Stream.hh1
3 files changed, 25 insertions, 11 deletions
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 5704e83f..b4d14441 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -235,9 +235,10 @@ QPDF_Stream::filterable(std::vector<std::string>& filters,
if (! filters_okay)
{
QTC::TC("qpdf", "QPDF_Stream invalid filter");
- throw QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
- "", this->offset,
- "stream filter type is not name or array");
+ warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
+ "", this->offset,
+ "stream filter type is not name or array"));
+ return false;
}
bool filterable = true;
@@ -300,12 +301,16 @@ QPDF_Stream::filterable(std::vector<std::string>& filters,
// /Filters was empty has been seen in the wild.
if ((filters.size() != 0) && (decode_parms.size() != filters.size()))
{
- // We should just issue a warning and treat this as not
- // filterable.
- throw QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
- "", this->offset,
- "stream /DecodeParms length is"
- " inconsistent with filters");
+ warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
+ "", this->offset,
+ "stream /DecodeParms length is"
+ " inconsistent with filters"));
+ filterable = false;
+ }
+
+ if (! filterable)
+ {
+ return false;
}
for (unsigned int i = 0; i < filters.size(); ++i)
@@ -454,7 +459,9 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool filter,
else
{
QTC::TC("qpdf", "QPDF_Stream provider length mismatch");
- throw std::logic_error(
+ // This would be caused by programmer error on the
+ // part of a library user, not by invalid input data.
+ throw std::runtime_error(
"stream data provider for " +
QUtil::int_to_string(this->objid) + " " +
QUtil::int_to_string(this->generation) +
@@ -542,3 +549,9 @@ QPDF_Stream::replaceDict(QPDFObjectHandle new_dict)
this->length = 0;
}
}
+
+void
+QPDF_Stream::warn(QPDFExc const& e)
+{
+ QPDF::Warner::warn(this->qpdf, e);
+}
diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc
index 975e9707..797476c1 100644
--- a/libqpdf/qpdf-c.cc
+++ b/libqpdf/qpdf-c.cc
@@ -646,6 +646,6 @@ QPDF_ERROR_CODE qpdf_write(qpdf_data qpdf)
{
QPDF_ERROR_CODE status = QPDF_SUCCESS;
status = trap_errors(qpdf, &call_write);
- QTC::TC("qpdf", "qpdf-c called qpdf_write", status);
+ QTC::TC("qpdf", "qpdf-c called qpdf_write", (status == 0) ? 0 : 1);
return status;
}
diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh
index 5a5d555b..fa405d70 100644
--- a/libqpdf/qpdf/QPDF_Stream.hh
+++ b/libqpdf/qpdf/QPDF_Stream.hh
@@ -52,6 +52,7 @@ class QPDF_Stream: public QPDFObject
int& predictor, int& columns, bool& early_code_change);
bool filterable(std::vector<std::string>& filters,
int& predictor, int& columns, bool& early_code_change);
+ void warn(QPDFExc const& e);
QPDF* qpdf;
int objid;