[Libreoffice-commits] core.git: external/pdfium
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 17 08:09:15 UTC 2020
external/pdfium/FPDF_GetTrailerEnds-make-this-not-depend-on-whitespa.patch.1 | 55 ++++++++++
external/pdfium/UnpackedTarball_pdfium.mk | 3
2 files changed, 58 insertions(+)
New commits:
commit 89d8c762496cf874d6352167df280c33b7ba5ea0
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Dec 16 21:03:44 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Dec 17 09:08:37 2020 +0100
pdfium: backport GetTrailerEnds whitespace fix
Fixes the problem that sometimes a valid sig is detected as a partial
one.
Change-Id: I68107569bf8c331170902b1918a70ea4b9b659a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107856
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/external/pdfium/FPDF_GetTrailerEnds-make-this-not-depend-on-whitespa.patch.1 b/external/pdfium/FPDF_GetTrailerEnds-make-this-not-depend-on-whitespa.patch.1
new file mode 100644
index 000000000000..10398bae6415
--- /dev/null
+++ b/external/pdfium/FPDF_GetTrailerEnds-make-this-not-depend-on-whitespa.patch.1
@@ -0,0 +1,55 @@
+From c10d17dee78d48d5e56da965e0cd02d28fd513a5 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Wed, 9 Dec 2020 17:42:53 +0000
+Subject: [PATCH] FPDF_GetTrailerEnds: make this not depend on whitespace
+
+PDF-1.7 calls out no bytes other than whitespace when specifying what
+can occur between endstream and endobj, so whitespace needs to be
+handled. When CPDF_SyntaxParser::ReadStream() reads the stream, it reads
+'endobj', and then resets the position back to the end of 'endstream'.
+This mechanism is disabled in case there is whitespace between the
+tokens and the newline, see the end of the function.
+
+This results in reporting no trailer ends, as the parsing fails, as the
+next token is expected to be 'endobj', but it's the ID of the next
+object instead.
+
+Fix the problem by handling whitespace in
+CPDF_SyntaxParser::ReadStream() where it was looking for \ntoken\n, not
+allowing whitespace between the token and the following newline.
+
+Change-Id: I7048e8d081af04af3dd08d957212c885b7982b5e
+Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/76850
+Commit-Queue: Tom Sepez <tsepez at chromium.org>
+Reviewed-by: Tom Sepez <tsepez at chromium.org>
+---
+ core/fpdfapi/parser/cpdf_syntax_parser.cpp | 8 ++
+ fpdfsdk/fpdf_view_embeddertest.cpp | 14 +++
+ .../resources/trailer_end_trailing_space.in | 86 ++++++++++++++++
+ .../resources/trailer_end_trailing_space.pdf | 99 +++++++++++++++++++
+ 4 files changed, 207 insertions(+)
+ create mode 100644 testing/resources/trailer_end_trailing_space.in
+ create mode 100644 testing/resources/trailer_end_trailing_space.pdf
+
+diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+index 06389bccc..5318efdc1 100644
+--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
++++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+@@ -795,6 +795,14 @@ RetainPtr<CPDF_Stream> CPDF_SyntaxParser::ReadStream(
+ memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1);
+ GetNextWordInternal(nullptr);
+
++ // Allow whitespace after endstream and before a newline.
++ unsigned char ch = 0;
++ while (GetNextChar(ch)) {
++ if (!PDFCharIsWhitespace(ch) || PDFCharIsLineEnding(ch))
++ break;
++ }
++ SetPos(GetPos() - 1);
++
+ int numMarkers = ReadEOLMarkers(GetPos());
+ if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) &&
+ numMarkers != 0 &&
+--
+2.26.2
+
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index c0cc000e40be..87012e73f931 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -17,7 +17,10 @@ pdfium_patches += c++20-comparison.patch
pdfium_patches += AnnotationInkAndVertices.patch.1
pdfium_patches += AnnotationBorderProperties.patch.1
pdfium_patches += AnnotationLineStartAndEnd.patch.1
+# Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/75910>.
pdfium_patches += SignatureGetDocMDPPermission.patch.1
+# Backport of <https://pdfium-review.googlesource.com/c/pdfium/+/76850>.
+pdfium_patches += FPDF_GetTrailerEnds-make-this-not-depend-on-whitespa.patch.1
# Work around <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94141> "c++20 rewritten operator==
# recursive call mixing friend and external operators for template class" in GCC with
More information about the Libreoffice-commits
mailing list