summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-07-20 08:16:57 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-07-20 19:47:50 +0200
commit3b74fc4419cdf066b4cbf770df84e2a1209ad072 (patch)
treee522d81697964a46a53b9df65a1843f834fcbc48 /xmlsecurity
parent06229e4df02ddccb0408538271e0fbf683847355 (diff)
tdf#127236 vcl: fix missing encryption of PDF images during export
Regression from commit 78e25558e86188314b9b72048b8ddca18697cb86 (tdf#106059 PDF export: create a reference XObject for JPG images with PDF data, 2017-02-23), once a PDF image was inserted to a document, an encrypted PDF export lost those images. The reason for this is that we started to preserve PDF images as vector data with the above commit, but this means we copied over PDF objects from PDF images to the export result as-is, so encryption was not performed for them. Fix this by separating the write of the PDF object headers, stream content and object footer and then calling checkAndEnableStreamEncryption() / disableStreamEncryption() for each object, even if it's not something our PDF export created but comes from a PDF image. Note that when existing PDF files are signed, PDF objects are also copied into a vcl::filter::PDFDocument, but such PDF images are never encrypted, so it's fine to have stub implementations in vcl::filter::PDFDocument. (cherry picked from commit 7d56dae3375dc0180aa6d20983b3f5f962302588) Change-Id: I2f74b9f51cd35b4319221532ca890e197bab9cf3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137260 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx2
-rw-r--r--xmlsecurity/source/helper/pdfsignaturehelper.cxx4
2 files changed, 3 insertions, 3 deletions
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 9e28f90d55d1..c3c5d254b335 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -845,7 +845,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFAddVisibleSignature)
SvMemoryStream aMemory;
aMemory.WriteStream(aFile);
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
- = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize());
+ = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), OString());
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnot = pPdfPage->getAnnotation(/*nIndex=*/0);
diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
index 5aa2088ea7fd..48d5c7f2db3a 100644
--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
@@ -255,7 +255,7 @@ void AnalyizeSignatureStream(SvMemoryStream& rStream, std::vector<PageChecksum>&
{
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
- = pPdfium->openDocument(rStream.GetData(), rStream.GetSize());
+ = pPdfium->openDocument(rStream.GetData(), rStream.GetSize(), OString());
if (!pPdfDocument)
{
return;
@@ -435,7 +435,7 @@ bool PDFSignatureHelper::ReadAndVerifySignatureSvStream(SvStream& rStream)
aStream.WriteStream(rStream);
rStream.Seek(nPos);
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
- = pPdfium->openDocument(aStream.GetData(), aStream.GetSize());
+ = pPdfium->openDocument(aStream.GetData(), aStream.GetSize(), OString());
if (!pPdfDocument)
{
SAL_WARN("xmlsecurity.helper", "failed to read the document");