Commit fc88837d4b04c8b766c973206303c3d3af334b92
1 parent
6fe7b704
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.
Showing
2 changed files
with
13 additions
and
11 deletions
ChangeLog
| 1 | +2021-01-11 Jay Berkenbilt <ejb@ql.org> | |
| 2 | + | |
| 3 | + * Fix very old error in code that was finding attachment streams. | |
| 4 | + Probably this error never mattered, but the code was still not | |
| 5 | + exactly right. | |
| 6 | + | |
| 1 | 7 | 2021-01-06 Jay Berkenbilt <ejb@ql.org> |
| 2 | 8 | |
| 3 | 9 | * Give warnings instead of segfaulting if a QPDF operation is | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | #include <qpdf/FileInputSource.hh> |
| 19 | 19 | #include <qpdf/BufferInputSource.hh> |
| 20 | 20 | #include <qpdf/OffsetInputSource.hh> |
| 21 | +#include <qpdf/QPDFNameTreeObjectHelper.hh> | |
| 21 | 22 | |
| 22 | 23 | #include <qpdf/QPDFExc.hh> |
| 23 | 24 | #include <qpdf/QPDF_Null.hh> |
| ... | ... | @@ -3004,22 +3005,17 @@ QPDF::findAttachmentStreams() |
| 3004 | 3005 | { |
| 3005 | 3006 | return; |
| 3006 | 3007 | } |
| 3007 | - QPDFObjectHandle embeddedFiles = names.getKey("/EmbeddedFiles"); | |
| 3008 | - if (! embeddedFiles.isDictionary()) | |
| 3008 | + QPDFObjectHandle embedded_files = names.getKey("/EmbeddedFiles"); | |
| 3009 | + if (! embedded_files.isDictionary()) | |
| 3009 | 3010 | { |
| 3010 | 3011 | return; |
| 3011 | 3012 | } |
| 3012 | - names = embeddedFiles.getKey("/Names"); | |
| 3013 | - if (! names.isArray()) | |
| 3013 | + QPDFNameTreeObjectHelper ef_tree(embedded_files); | |
| 3014 | + auto ef_tree_map = ef_tree.getAsMap(); | |
| 3015 | + for (auto& i: ef_tree_map) | |
| 3014 | 3016 | { |
| 3015 | - return; | |
| 3016 | - } | |
| 3017 | - for (int i = 0; i < names.getArrayNItems(); ++i) | |
| 3018 | - { | |
| 3019 | - QPDFObjectHandle item = names.getArrayItem(i); | |
| 3017 | + QPDFObjectHandle item = i.second; | |
| 3020 | 3018 | if (item.isDictionary() && |
| 3021 | - item.getKey("/Type").isName() && | |
| 3022 | - (item.getKey("/Type").getName() == "/Filespec") && | |
| 3023 | 3019 | item.getKey("/EF").isDictionary() && |
| 3024 | 3020 | item.getKey("/EF").getKey("/F").isStream()) |
| 3025 | 3021 | { | ... | ... |