xmloff/source/core/xmlexp.cxx |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 2184692bbe69a093368e959e1096cb7506feceee
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Jan 8 19:44:50 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Jan 9 14:30:42 2024 +0100

    xmloff: ODF export: if there's no checksum, don't generate chaff
    
    Change-Id: I2e1bb6ed33df327ebd797edeca7ee82b75c524b4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161800
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 9900fa4d86fe..bb7ef1cc695d 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -95,7 +95,7 @@
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/document/XMLOasisBasicExporter.hpp>
-#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
+#include <com/sun/star/embed/XEncryptionProtectedStorage.hpp>
 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
 #include <com/sun/star/rdf/XMetadatable.hpp>
 #include <RDFaExportHelper.hxx>
@@ -1188,10 +1188,22 @@ lcl_AddGrddl(SvXMLExport const & rExport, const 
SvXMLExportFlags /*nExportMode*/
 // note: the point of this is presumably to mitigate SHA/1k info leak of plain 
text
 void SvXMLExport::addChaffWhenEncryptedStorage()
 {
-    uno::Reference< embed::XEncryptionProtectedSource2 > 
xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
+    uno::Reference<embed::XEncryptionProtectedStorage> const 
xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
 
     if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
     {
+        uno::Sequence<beans::NamedValue> const 
algo(xEncr->getEncryptionAlgorithms());
+        for (auto const& it : algo)
+        {
+            if (it.Name == "ChecksumAlgorithm")
+            {
+                if (!it.Value.hasValue())
+                {
+                    return; // no checksum => no chaff
+                }
+                break;
+            }
+        }
         
mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), 
RTL_TEXTENCODING_ASCII_US));
     }
 }

Reply via email to