From 0e51a9aca61dfc2cc44bf19a6ba23d423d7f204c Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 28 Aug 2019 22:48:55 -0400 Subject: [PATCH] Don't encrypt trailer, fixes fuzz issue 15983 --- fuzz/qpdf_extra/15983.fuzz | Bin 0 -> 830412 bytes libqpdf/QPDFWriter.cc | 11 +++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 fuzz/qpdf_extra/15983.fuzz diff --git a/fuzz/qpdf_extra/15983.fuzz b/fuzz/qpdf_extra/15983.fuzz new file mode 100644 index 0000000..7e3366d Binary files /dev/null and b/fuzz/qpdf_extra/15983.fuzz differ diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index f5fa2bc..116d493 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1341,7 +1341,11 @@ QPDFWriter::writeTrailer(trailer_e which, int size, bool xref_stream, qpdf_offset_t prev, int linearization_pass) { QPDFObjectHandle trailer = getTrimmedTrailer(); - if (! xref_stream) + if (xref_stream) + { + this->m->cur_data_key.clear(); + } + else { writeString("trailer <<"); } @@ -3320,7 +3324,10 @@ QPDFWriter::writeLinearized() if (this->m->pipeline->getCount() != first_xref_end) { throw std::logic_error( - "insufficient padding for first pass xref stream"); + "insufficient padding for first pass xref stream; " + "first_xref_end=" + + QUtil::int_to_string(first_xref_end) + + "; endpos=" + QUtil::int_to_string(endpos)); } } writeString("\n"); -- libgit2 0.21.4