Treat /EmbeddedFiles as a proper name tree

If we ever had an encrypted file with different filters for
attachments and either the /EmbeddedFiles name tree was deep or some
of the file specs didn't have /Type, we would have overlooked those as
attachment streams. The code now properly handles /EmbeddedFiles as a
name tree.
This commit is contained in:
Jay Berkenbilt 2021-01-11 10:50:39 -05:00
parent 6fe7b704c7
commit fc88837d4b
2 changed files with 13 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2021-01-11 Jay Berkenbilt <ejb@ql.org>
* Fix very old error in code that was finding attachment streams.
Probably this error never mattered, but the code was still not
exactly right.
2021-01-06 Jay Berkenbilt <ejb@ql.org>
* Give warnings instead of segfaulting if a QPDF operation is

View File

@ -18,6 +18,7 @@
#include <qpdf/FileInputSource.hh>
#include <qpdf/BufferInputSource.hh>
#include <qpdf/OffsetInputSource.hh>
#include <qpdf/QPDFNameTreeObjectHelper.hh>
#include <qpdf/QPDFExc.hh>
#include <qpdf/QPDF_Null.hh>
@ -3004,22 +3005,17 @@ QPDF::findAttachmentStreams()
{
return;
}
QPDFObjectHandle embeddedFiles = names.getKey("/EmbeddedFiles");
if (! embeddedFiles.isDictionary())
QPDFObjectHandle embedded_files = names.getKey("/EmbeddedFiles");
if (! embedded_files.isDictionary())
{
return;
}
names = embeddedFiles.getKey("/Names");
if (! names.isArray())
QPDFNameTreeObjectHelper ef_tree(embedded_files);
auto ef_tree_map = ef_tree.getAsMap();
for (auto& i: ef_tree_map)
{
return;
}
for (int i = 0; i < names.getArrayNItems(); ++i)
{
QPDFObjectHandle item = names.getArrayItem(i);
QPDFObjectHandle item = i.second;
if (item.isDictionary() &&
item.getKey("/Type").isName() &&
(item.getKey("/Type").getName() == "/Filespec") &&
item.getKey("/EF").isDictionary() &&
item.getKey("/EF").getKey("/F").isStream())
{