[Libreoffice-commits] core.git: xmlsecurity/qa xmlsecurity/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Dec 1 16:26:39 UTC 2016


 xmlsecurity/qa/unit/pdfsigning/data/dict-bool.pdf |binary
 xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx     |    2 ++
 xmlsecurity/source/pdfio/pdfdocument.cxx          |   12 +++++++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit c623a9f846c713b19a0d58337af4f4354aeffa6e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 1 13:41:37 2016 +0100

    xmlsecurity PDF verify: handle boolean type as dictionary value
    
    This caused not finding the length of a stream -> could not actually
    verify signature.
    
    Change-Id: I696b6da49525eb53f7575c27f619d2116be51f1d
    Reviewed-on: https://gerrit.libreoffice.org/31490
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/xmlsecurity/qa/unit/pdfsigning/data/dict-bool.pdf b/xmlsecurity/qa/unit/pdfsigning/data/dict-bool.pdf
new file mode 100644
index 0000000..cd87f71
Binary files /dev/null and b/xmlsecurity/qa/unit/pdfsigning/data/dict-bool.pdf differ
diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index c10752b..1ecbb22 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -357,6 +357,8 @@ void PDFSigningTest::testGood()
     {
         // We failed to determine if this is good or bad.
         OUStringLiteral("good-non-detached.pdf"),
+        // Boolean value for dictionary key caused read error.
+        OUStringLiteral("dict-bool.pdf"),
     };
 
     for (const auto& rName : aNames)
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index 34a7474..b19a043 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -2122,7 +2122,7 @@ bool PDFDocument::ValidateSignature(SvStream& rStream, PDFObjectElement* pSignat
     auto pSubFilter = dynamic_cast<PDFNameElement*>(pValue->Lookup("SubFilter"));
     if (!pSubFilter || (pSubFilter->GetValue() != "adbe.pkcs7.detached" && pSubFilter->GetValue() != "adbe.pkcs7.sha1" && pSubFilter->GetValue() != "ETSI.CAdES.detached"))
     {
-        SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ValidateSignature: no or unsupported sub-filter");
+        SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ValidateSignature: unsupported sub-filter: '"<<pSubFilter->GetValue()<<"'");
         return false;
     }
 
@@ -2976,6 +2976,16 @@ size_t PDFDictionaryElement::Parse(const std::vector< std::unique_ptr<PDFElement
             continue;
         }
 
+        auto pBoolean = dynamic_cast<PDFBooleanElement*>(rElements[i].get());
+        if (pBoolean)
+        {
+            rDictionary[aName] = pBoolean;
+            if (pThisDictionary)
+                pThisDictionary->SetKeyOffset(aName, nNameOffset);
+            aName.clear();
+            continue;
+        }
+
         auto pHexString = dynamic_cast<PDFHexStringElement*>(rElements[i].get());
         if (pHexString)
         {


More information about the Libreoffice-commits mailing list