From e076c9bf084ba5f90f52d829255e4ef04e3a8031 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 6 Feb 2021 16:25:10 -0500 Subject: Remove erroneous handling of /EFF for stream decryption I thought /EFF was supposed to be used as a default for decrypting embedded file streams, but actually it's supposed to be advice to a conforming writer about handling new ones. This makes sense since the findAttachmentStreams code, which is not actually needed, was never right. --- libqpdf/QPDF.cc | 48 +++++------------------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 89c6ed74..3209903f 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -98,7 +97,6 @@ QPDF::ForeignStreamData::ForeignStreamData( int foreign_generation, qpdf_offset_t offset, size_t length, - bool is_attachment_stream, QPDFObjectHandle local_dict) : encp(encp), @@ -107,7 +105,6 @@ QPDF::ForeignStreamData::ForeignStreamData( foreign_generation(foreign_generation), offset(offset), length(length), - is_attachment_stream(is_attachment_stream), local_dict(local_dict) { } @@ -508,7 +505,6 @@ QPDF::parse(char const* password) } initializeEncryption(); - findAttachmentStreams(); this->m->parsed = true; } @@ -2648,8 +2644,6 @@ QPDF::replaceForeignIndirectObjects( foreign.getGeneration(), stream->getOffset(), stream->getLength(), - (foreign_stream_qpdf->m->attachment_streams.count( - foreign.getObjGen()) > 0), dict); this->m->copied_stream_data_provider->registerForeignStream( local_og, foreign_stream_data); @@ -2882,7 +2876,6 @@ QPDF::pipeStreamData(PointerHolder encp, int objid, int generation, qpdf_offset_t offset, size_t length, QPDFObjectHandle stream_dict, - bool is_attachment_stream, Pipeline* pipeline, bool suppress_warnings, bool will_retry) @@ -2892,7 +2885,7 @@ QPDF::pipeStreamData(PointerHolder encp, { decryptStream(encp, file, qpdf_for_warning, pipeline, objid, generation, - stream_dict, is_attachment_stream, to_delete); + stream_dict, to_delete); } bool success = false; @@ -2968,14 +2961,11 @@ QPDF::pipeStreamData(int objid, int generation, bool suppress_warnings, bool will_retry) { - bool is_attachment_stream = ( - this->m->attachment_streams.count( - QPDFObjGen(objid, generation)) > 0); return pipeStreamData( this->m->encp, this->m->file, *this, objid, generation, offset, length, - stream_dict, is_attachment_stream, - pipeline, suppress_warnings, will_retry); + stream_dict, pipeline, + suppress_warnings, will_retry); } bool @@ -2992,36 +2982,8 @@ QPDF::pipeForeignStreamData( foreign->encp, foreign->file, *this, foreign->foreign_objid, foreign->foreign_generation, foreign->offset, foreign->length, - foreign->local_dict, foreign->is_attachment_stream, - pipeline, suppress_warnings, will_retry); -} - -void -QPDF::findAttachmentStreams() -{ - QPDFObjectHandle root = getRoot(); - QPDFObjectHandle names = root.getKey("/Names"); - if (! names.isDictionary()) - { - return; - } - QPDFObjectHandle embedded_files = names.getKey("/EmbeddedFiles"); - if (! embedded_files.isDictionary()) - { - return; - } - QPDFNameTreeObjectHelper ef_tree(embedded_files, *this); - for (auto const& i: ef_tree) - { - QPDFObjectHandle item = i.second; - if (item.isDictionary() && - item.getKey("/EF").isDictionary() && - item.getKey("/EF").getKey("/F").isStream()) - { - QPDFObjectHandle stream = item.getKey("/EF").getKey("/F"); - this->m->attachment_streams.insert(stream.getObjGen()); - } - } + foreign->local_dict, pipeline, + suppress_warnings, will_retry); } void -- cgit v1.2.3-54-g00ecf