[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-5-2' - 16 commits - configure.ac download.lst external/curl external/liborcus external/poppler RepositoryExternal.mk

Michael Stahl Michael.Stahl at cib.de
Mon Jul 9 11:56:56 UTC 2018


 RepositoryExternal.mk                                                             |    6 
 configure.ac                                                                      |   17 
 download.lst                                                                      |    8 
 external/curl/CVE-2017-8816.patch                                                 |   67 +
 external/curl/CVE-2018-1000005.patch                                              |   36 
 external/curl/CVE-2018-1000007.patch                                              |  110 ++
 external/curl/UnpackedTarball_curl.mk                                             |    3 
 external/liborcus/0001-protect-the-self-closing-xml-element-code-against-se.patch |   30 
 external/liborcus/UnpackedTarball_liborcus.mk                                     |    1 
 external/poppler/ExternalProject_poppler.mk                                       |   51 -
 external/poppler/Module_poppler.mk                                                |    2 
 external/poppler/StaticLibrary_poppler.mk                                         |  144 ++
 external/poppler/UnpackedTarball_poppler.mk                                       |    8 
 external/poppler/poppler-0.46.0-std-max.patch.1                                   |   10 
 external/poppler/poppler-0.46.0-unused-private-field.patch.1                      |   11 
 external/poppler/poppler-config.patch.1                                           |  484 ++++++++++
 external/poppler/poppler-libjpeg.patch.1                                          |   23 
 external/poppler/poppler-mac-fake.patch.1                                         |   13 
 external/poppler/poppler-notests.patch.1                                          |   11 
 external/poppler/poppler-snprintf.patch.1                                         |    2 
 external/poppler/poppler-vs2013.patch.1                                           |   11 
 external/poppler/ubsan.patch.0                                                    |   58 -
 22 files changed, 890 insertions(+), 216 deletions(-)

New commits:
commit e0402228e5ea0301140d47aaabd88f0820711e81
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Thu Jun 28 18:30:28 2018 +0200

    python3: upgrade to release 3.5.5
    
    Fixes CVE-2017-1000158.
    
    Change-Id: I1871f031e3431253a3403f2ea2b586bcc4aa1016
    Reviewed-on: https://gerrit.libreoffice.org/56609
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 744feb55a11263ae0947ab59db76b949b5863acf)
    Reviewed-on: https://gerrit.libreoffice.org/56684
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/configure.ac b/configure.ac
index 57fbf74923ab..65767648de35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8247,7 +8247,7 @@ internal)
         PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.5
     else
         PYTHON_VERSION_MINOR=5
-        PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.4
+        PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.5
     fi
     if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
         AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
diff --git a/download.lst b/download.lst
index 6309c54993a5..49ed2b743f72 100644
--- a/download.lst
+++ b/download.lst
@@ -137,8 +137,8 @@ ifeq ($(PYTHON_VERSION_MINOR),3)
 export PYTHON_MD5SUM := 803a75927f8f241ca78633890c798021
 export PYTHON_TARBALL := Python-3.3.5.tgz
 else
-export PYTHON_MD5SUM := 2ed4802b7a2a7e40d2e797272bf388ec
-export PYTHON_TARBALL := Python-3.5.4.tgz
+export PYTHON_MD5SUM := f3763edf9824d5d3a15f5f646083b6e0
+export PYTHON_TARBALL := Python-3.5.5.tar.xz
 endif
 
 export RAPTOR_TARBALL := 4ceb9316488b0ea01acf011023cf7fff-raptor2-2.0.9.tar.gz
commit ae95578fcd87cb9d12f857bc68c88abd658bf161
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 22 22:26:43 2017 +0200

    configure: try to keep PYTHON_VERSION from going stale
    
    Since it was set to 3.5.0, the bundled python was upgraded twice, but
    the directory is still named python-core-3.5.0 :(
    
    Change-Id: I15eec4148c2436e1f289d9851ce5bd212d4a368a
    Reviewed-on: https://gerrit.libreoffice.org/41433
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit ac3a4fe35e873de17eefb46c3f5e792aded6b0a5)
    Reviewed-on: https://gerrit.libreoffice.org/56683
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/configure.ac b/configure.ac
index 3512693d23d5..57fbf74923ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8244,10 +8244,14 @@ internal)
     # when MSVC 2013 support was dropped.
     if test "$COM" = "MSC" -a "$VCVER" = "120"; then
         PYTHON_VERSION_MINOR=3
+        PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.5
     else
         PYTHON_VERSION_MINOR=5
+        PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.4
+    fi
+    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
+        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
     fi
-    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.0
     AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
     BUILD_TYPE="$BUILD_TYPE PYTHON"
     # Embedded Python dies without Home set
commit 9c3a0c9e5f33d1a53afe76135739896dfa63fc2a
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Mon Jun 25 11:30:09 2018 +0200

    poppler: fix incorrect GCC_VERSION check
    
    The minor version is encoded into the last 2 digits, the micro version
    is not avialable.
    
    Change-Id: I4eee40511d732ec8cfc8d85943b965bb6e06d66e
    Reviewed-on: https://gerrit.libreoffice.org/56380
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Jenkins
    (cherry picked from commit 16b10d9ac976d40daffee1d15456016f4a89cd2e)
    Reviewed-on: https://gerrit.libreoffice.org/56388
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/external/poppler/StaticLibrary_poppler.mk b/external/poppler/StaticLibrary_poppler.mk
index da85aff3f710..fd7f5c467973 100644
--- a/external/poppler/StaticLibrary_poppler.mk
+++ b/external/poppler/StaticLibrary_poppler.mk
@@ -34,11 +34,12 @@ $(eval $(call gb_StaticLibrary_add_cxxflags,poppler,\
 endif
 
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58864
+# can't easily check for 4.8.2 exactly so just apply to GCC 4.8.x
 ifeq ($(COM),GCC)
 ifeq ($(COM_IS_CLANG),)
 ifeq ($(CPUNAME),INTEL)
-ifeq ($(shell expr '$(GCC_VERSION)' '<' 483),1)
-ifeq ($(shell expr '$(GCC_VERSION)' '>=' 480),1)
+ifeq ($(shell expr '$(GCC_VERSION)' '<' 409),1)
+ifeq ($(shell expr '$(GCC_VERSION)' '>=' 408),1)
 $(eval $(call gb_StaticLibrary_add_cxxflags,poppler,\
 	-march=i586 \
 ))
commit b3450c197e8c5349cbe452ebb9f79f291e8b8383
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Fri Jun 22 10:44:02 2018 +0200

    poppler: try to work around GCC 4.8.2 bug
    
    As seen on Linux-rpm_deb-x86 at 71-TDF:
    
    poppler/Annot.cc:2491:1: internal compiler error: in connect_traces, at dwarf2cfi.c:2676
    
    The bug report claims that -march=i586 works around the bug.
    
    Change-Id: I1d97d2df9049e058d49987424cc8e4818a9fa9c6
    (cherry picked from commit 1c7921c43960a4a6717c816d646cf0f65fbaec12)
    Reviewed-on: https://gerrit.libreoffice.org/56292
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit dce6401f7e1f466c30996ad606699479713209e5)
    Reviewed-on: https://gerrit.libreoffice.org/56299
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/external/poppler/StaticLibrary_poppler.mk b/external/poppler/StaticLibrary_poppler.mk
index bb5f51b571ca..da85aff3f710 100644
--- a/external/poppler/StaticLibrary_poppler.mk
+++ b/external/poppler/StaticLibrary_poppler.mk
@@ -33,6 +33,21 @@ $(eval $(call gb_StaticLibrary_add_cxxflags,poppler,\
 ))
 endif
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58864
+ifeq ($(COM),GCC)
+ifeq ($(COM_IS_CLANG),)
+ifeq ($(CPUNAME),INTEL)
+ifeq ($(shell expr '$(GCC_VERSION)' '<' 483),1)
+ifeq ($(shell expr '$(GCC_VERSION)' '>=' 480),1)
+$(eval $(call gb_StaticLibrary_add_cxxflags,poppler,\
+	-march=i586 \
+))
+endif
+endif
+endif
+endif
+endif
+
 $(eval $(call gb_StaticLibrary_set_generated_cxx_suffix,poppler,cc))
 
 $(eval $(call gb_StaticLibrary_add_generated_exception_objects,poppler,\
commit 15cbef65b217e3ca09a5624ecd82624e4ed93785
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Fri Jun 22 10:52:37 2018 +0200

    poppler: poppler-snprintf.patch.1 needs rebase
    
    Presumably it's needed for MSVC 2013.
    
    Change-Id: Ibcd3bab373616faa58db4dab0f92f058d1dfafac
    Reviewed-on: https://gerrit.libreoffice.org/56274
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/external/poppler/poppler-snprintf.patch.1 b/external/poppler/poppler-snprintf.patch.1
index aaced8e099c2..baf3e6926c36 100644
--- a/external/poppler/poppler-snprintf.patch.1
+++ b/external/poppler/poppler-snprintf.patch.1
@@ -28,8 +28,8 @@
 +#    include <systools/win32/snprintf.h>
 +#  endif
  #endif
+ #include "goo/glibc.h"
  #include "goo/gmem.h"
- #include "goo/GooString.h"
 --- poppler-0.22.5/poppler/PageLabelInfo.cc	2013-03-25 22:48:34.000000000 +0100
 +++ poppler-0.22.5/poppler/PageLabelInfo.cc	2013-07-08 16:56:47.977901129 +0200
 @@ -17,6 +17,14 @@
commit df46a8beb12639b0cdf6a23d2c1107ffd7f7c86c
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Wed Jun 20 16:10:44 2018 +0200

    poppler: upgrade to release 0.66.0
    
    Unfortunately the autotools build system was removed in 0.60.0, and the
    CMake one is a bit overeager in linking against system libraries that
    happen to be installed on the build machine, and we currently don't
    require CMake anyway, so avoid the problems by using a gbuild makefile
    and a patch to add the generated header files.
    
    Remove all current patches:
    
    poppler-notests.patch.1: obsolete (autotools build system)
    
    poppler-mac-fake.patch.1: presumed obsolete
    
    ubsan.patch.0: presumably fixed differently upstream in
    https://cgit.freedesktop.org/poppler/poppler/commit/?id=f43cb73939f85952d83afc87a6dc638dc1ae311b
    
    poppler-libjpeg.patch.1: obsolete (autotools build system; there appears
    to be no way to do this with CMake?)
    
    0001-Fix-building-with-old-clang.patch.1: merged upstream
    
    Change-Id: I271c87ab3ec25cc9d1e8fafb04dae7c004acc350
    (cherry picked from commit 5f8426a077ec0986a4b6cf8a58515ad5496f78e0)
    Reviewed-on: https://gerrit.libreoffice.org/56259
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 24bbab79fc27..22fd07859a54 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2693,11 +2693,7 @@ $(call gb_LinkTarget_set_include,$(1),\
 	$$(INCLUDE) \
 )
 
-$(call gb_LinkTarget_add_libs,$(1),\
-	$(call gb_UnpackedTarball_get_dir,poppler)/fofi/.libs/libfofi$(gb_StaticLibrary_PLAINEXT) \
-	$(call gb_UnpackedTarball_get_dir,poppler)/goo/.libs/libgoo$(gb_StaticLibrary_PLAINEXT) \
-	$(call gb_UnpackedTarball_get_dir,poppler)/poppler/.libs/libpoppler$(gb_StaticLibrary_PLAINEXT) \
-)
+$(call gb_LinkTarget_use_static_libraries,$(1),poppler)
 
 $(call gb_LinkTarget_use_external,$(1),jpeg)
 
diff --git a/download.lst b/download.lst
index 5677ab58e433..6309c54993a5 100644
--- a/download.lst
+++ b/download.lst
@@ -129,8 +129,8 @@ export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
 export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
 export PNG_TARBALL := libpng-1.6.28.tar.gz
-export POPPLER_MD5SUM := 6e44408a3b4f4a738f8a6770d0aea8a5
-export POPPLER_TARBALL := poppler-0.59.0.tar.xz
+export POPPLER_MD5SUM := 6602813e52f02f85f11ba1590e0ef749
+export POPPLER_TARBALL := poppler-0.66.0.tar.xz
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 
 ifeq ($(PYTHON_VERSION_MINOR),3)
diff --git a/external/poppler/0001-Fix-building-with-old-clang.patch.1 b/external/poppler/0001-Fix-building-with-old-clang.patch.1
deleted file mode 100644
index dcddd11d2967..000000000000
--- a/external/poppler/0001-Fix-building-with-old-clang.patch.1
+++ /dev/null
@@ -1,25 +0,0 @@
-From dd80c182cbcb188af0dd590f222ba9bbb31e3fb7 Mon Sep 17 00:00:00 2001
-From: Albert Astals Cid <aacid at kde.org>
-Date: Mon, 4 Sep 2017 19:36:06 +0200
-Subject: [PATCH] Fix building with old clang
-
----
- poppler/StructElement.cc | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
-index 0fbd336a..451213f8 100644
---- a/poppler/StructElement.cc
-+++ b/poppler/StructElement.cc
-@@ -248,6 +248,8 @@ struct AttributeMapEntry {
- };
- 
- struct AttributeDefaults {
-+  AttributeDefaults() {}; // needed to support old clang
-+
-   Object Inline  = Object(objName, "Inline");
-   Object LrTb = Object(objName, "LrTb");
-   Object Normal = Object(objName, "Normal");
--- 
-2.13.5
-
diff --git a/external/poppler/ExternalProject_poppler.mk b/external/poppler/ExternalProject_poppler.mk
deleted file mode 100644
index 83d51b9ea9e7..000000000000
--- a/external/poppler/ExternalProject_poppler.mk
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_ExternalProject_ExternalProject,poppler))
-
-$(eval $(call gb_ExternalProject_use_autoconf,poppler,build))
-
-$(eval $(call gb_ExternalProject_use_externals,poppler,\
-	jpeg \
-))
-
-$(eval $(call gb_ExternalProject_register_targets,poppler,\
-	build \
-))
-
-$(call gb_ExternalProject_get_state_target,poppler,build) :
-	$(call gb_ExternalProject_run,build,\
-		$(if $(filter TRUE,$(DISABLE_DYNLOADING)),CFLAGS="$(CFLAGS) $(gb_VISIBILITY_FLAGS) $(gb_COMPILEROPTFLAGS)" CXXFLAGS="$(CXXFLAGS) $(gb_VISIBILITY_FLAGS) $(gb_VISIBILITY_FLAGS_CXX) $(gb_COMPILEROPTFLAGS)",$(if $(filter MSC-120,$(COM)-$(VCVER)),CXXFLAGS="$(CXXFLAGS) -I$(SRCDIR)/include")) \
-		MAKE=$(MAKE) PKG_CONFIG="" ./configure \
-			--with-pic \
-			--enable-static \
-			--disable-shared \
-			--enable-xpdf-headers \
-			--disable-poppler-cpp \
-			--enable-libopenjpeg=none \
-			--disable-libtiff \
-			--enable-libjpeg \
-			--disable-libpng \
-			--disable-zlib \
-			--disable-libcurl \
-			--disable-splash-output \
-			--disable-cairo-output \
-			--disable-poppler-glib \
-			--disable-poppler-qt4 \
-			--disable-poppler-qt5 \
-			--disable-gtk-test \
-			--disable-utils \
-			--disable-cms \
-			$(if $(verbose),--disable-silent-rules,--enable-silent-rules) \
-			$(if $(filter WNT MACOSX,$(OS)),--with-font-configuration=win32,--with-font-configuration=fontconfig) \
-			$(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
-		&& $(MAKE) \
-	)
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/poppler/Module_poppler.mk b/external/poppler/Module_poppler.mk
index 357bc6dd365e..9ae5ed7c8633 100644
--- a/external/poppler/Module_poppler.mk
+++ b/external/poppler/Module_poppler.mk
@@ -12,7 +12,7 @@ $(eval $(call gb_Module_Module,poppler))
 ifeq ($(SYSTEM_POPPLER),)
 
 $(eval $(call gb_Module_add_targets,poppler,\
-	ExternalProject_poppler \
+	StaticLibrary_poppler \
 	UnpackedTarball_poppler \
 ))
 
diff --git a/external/poppler/StaticLibrary_poppler.mk b/external/poppler/StaticLibrary_poppler.mk
new file mode 100644
index 000000000000..bb5f51b571ca
--- /dev/null
+++ b/external/poppler/StaticLibrary_poppler.mk
@@ -0,0 +1,128 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_StaticLibrary_StaticLibrary,poppler))
+
+$(eval $(call gb_StaticLibrary_use_unpacked,poppler,poppler))
+
+$(eval $(call gb_StaticLibrary_use_external,poppler,jpeg))
+
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,poppler))
+
+$(eval $(call gb_StaticLibrary_set_include,poppler,\
+	-I$(WORKDIR)/UnpackedTarball/poppler \
+	-I$(WORKDIR)/UnpackedTarball/poppler/fofi \
+	-I$(WORKDIR)/UnpackedTarball/poppler/goo \
+	-I$(WORKDIR)/UnpackedTarball/poppler/poppler \
+	$$(INCLUDE) \
+))
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_StaticLibrary_add_defs,poppler,\
+	-DWIN32_LEAN_AND_MEAN \
+	-D_CRT_SECURE_NO_WARNINGS \
+))
+$(eval $(call gb_StaticLibrary_add_cxxflags,poppler,\
+	/Zc:wchar_t- \
+))
+endif
+
+$(eval $(call gb_StaticLibrary_set_generated_cxx_suffix,poppler,cc))
+
+$(eval $(call gb_StaticLibrary_add_generated_exception_objects,poppler,\
+	UnpackedTarball/poppler/goo/gfile \
+	UnpackedTarball/poppler/goo/gmempp \
+	UnpackedTarball/poppler/goo/GooList \
+	UnpackedTarball/poppler/goo/GooTimer \
+	UnpackedTarball/poppler/goo/GooString \
+	UnpackedTarball/poppler/goo/gmem \
+	UnpackedTarball/poppler/goo/FixedPoint \
+	UnpackedTarball/poppler/goo/NetPBMWriter \
+	UnpackedTarball/poppler/goo/PNGWriter \
+	UnpackedTarball/poppler/goo/TiffWriter \
+	UnpackedTarball/poppler/goo/JpegWriter \
+	UnpackedTarball/poppler/goo/ImgWriter \
+	UnpackedTarball/poppler/goo/gstrtod \
+	UnpackedTarball/poppler/goo/grandom \
+	UnpackedTarball/poppler/goo/glibc \
+	UnpackedTarball/poppler/goo/glibc_strtok_r \
+	UnpackedTarball/poppler/fofi/FoFiBase \
+	UnpackedTarball/poppler/fofi/FoFiEncodings \
+	UnpackedTarball/poppler/fofi/FoFiTrueType \
+	UnpackedTarball/poppler/fofi/FoFiType1 \
+	UnpackedTarball/poppler/fofi/FoFiType1C \
+	UnpackedTarball/poppler/fofi/FoFiIdentifier \
+	UnpackedTarball/poppler/poppler/Annot \
+	UnpackedTarball/poppler/poppler/Array \
+	UnpackedTarball/poppler/poppler/BuiltinFont \
+	UnpackedTarball/poppler/poppler/BuiltinFontTables \
+	UnpackedTarball/poppler/poppler/CachedFile \
+	UnpackedTarball/poppler/poppler/Catalog \
+	UnpackedTarball/poppler/poppler/CharCodeToUnicode \
+	UnpackedTarball/poppler/poppler/CMap \
+	UnpackedTarball/poppler/poppler/DateInfo \
+	UnpackedTarball/poppler/poppler/Decrypt \
+	UnpackedTarball/poppler/poppler/Dict \
+	UnpackedTarball/poppler/poppler/Error \
+	UnpackedTarball/poppler/poppler/FileSpec \
+	UnpackedTarball/poppler/poppler/FontEncodingTables \
+	UnpackedTarball/poppler/poppler/Form \
+	UnpackedTarball/poppler/poppler/FontInfo \
+	UnpackedTarball/poppler/poppler/Function \
+	UnpackedTarball/poppler/poppler/Gfx \
+	UnpackedTarball/poppler/poppler/GfxFont \
+	UnpackedTarball/poppler/poppler/GfxState \
+	UnpackedTarball/poppler/poppler/GlobalParams \
+	UnpackedTarball/poppler/poppler/Hints \
+	UnpackedTarball/poppler/poppler/JArithmeticDecoder \
+	UnpackedTarball/poppler/poppler/JBIG2Stream \
+	UnpackedTarball/poppler/poppler/Lexer \
+	UnpackedTarball/poppler/poppler/Link \
+	UnpackedTarball/poppler/poppler/Linearization \
+	UnpackedTarball/poppler/poppler/LocalPDFDocBuilder \
+	UnpackedTarball/poppler/poppler/MarkedContentOutputDev \
+	UnpackedTarball/poppler/poppler/NameToCharCode \
+	UnpackedTarball/poppler/poppler/Object \
+	UnpackedTarball/poppler/poppler/OptionalContent \
+	UnpackedTarball/poppler/poppler/Outline \
+	UnpackedTarball/poppler/poppler/OutputDev \
+	UnpackedTarball/poppler/poppler/Page \
+	UnpackedTarball/poppler/poppler/PageTransition \
+	UnpackedTarball/poppler/poppler/Parser \
+	UnpackedTarball/poppler/poppler/PDFDoc \
+	UnpackedTarball/poppler/poppler/PDFDocEncoding \
+	UnpackedTarball/poppler/poppler/PDFDocFactory \
+	UnpackedTarball/poppler/poppler/PopplerCache \
+	UnpackedTarball/poppler/poppler/ProfileData \
+	UnpackedTarball/poppler/poppler/PreScanOutputDev \
+	UnpackedTarball/poppler/poppler/PSTokenizer \
+	UnpackedTarball/poppler/poppler/SignatureInfo \
+	UnpackedTarball/poppler/poppler/Stream \
+	UnpackedTarball/poppler/poppler/StructTreeRoot \
+	UnpackedTarball/poppler/poppler/StructElement \
+	UnpackedTarball/poppler/poppler/UnicodeMap \
+	UnpackedTarball/poppler/poppler/UnicodeMapFuncs \
+	UnpackedTarball/poppler/poppler/UnicodeTypeTable \
+	UnpackedTarball/poppler/poppler/UTF \
+	UnpackedTarball/poppler/poppler/XRef \
+	UnpackedTarball/poppler/poppler/PSOutputDev \
+	UnpackedTarball/poppler/poppler/TextOutputDev \
+	UnpackedTarball/poppler/poppler/PageLabelInfo \
+	UnpackedTarball/poppler/poppler/SecurityHandler \
+	UnpackedTarball/poppler/poppler/StdinCachedFile \
+	UnpackedTarball/poppler/poppler/StdinPDFDocBuilder \
+	UnpackedTarball/poppler/poppler/Sound \
+	UnpackedTarball/poppler/poppler/ViewerPreferences \
+	UnpackedTarball/poppler/poppler/XpdfPluginAPI \
+	UnpackedTarball/poppler/poppler/Movie \
+	UnpackedTarball/poppler/poppler/Rendition \
+	UnpackedTarball/poppler/poppler/DCTStream \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index 94c8eb650dbc..f29933618b18 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -12,12 +12,8 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,poppler))
 $(eval $(call gb_UnpackedTarball_set_tarball,poppler,$(POPPLER_TARBALL),,poppler))
 
 $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
-	external/poppler/poppler-notests.patch.1 \
 	$(if $(filter MSC-120,$(COM)-$(VCVER)),external/poppler/poppler-snprintf.patch.1) \
-	external/poppler/poppler-mac-fake.patch.1 \
-	external/poppler/ubsan.patch.0 \
-	external/poppler/poppler-libjpeg.patch.1 \
-	external/poppler/0001-Fix-building-with-old-clang.patch.1 \
+	external/poppler/poppler-config.patch.1 \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/poppler/poppler-config.patch.1 b/external/poppler/poppler-config.patch.1
new file mode 100644
index 000000000000..5328e680e2f2
--- /dev/null
+++ b/external/poppler/poppler-config.patch.1
@@ -0,0 +1,484 @@
+*three* poppler config headers
+
+mkdir build && cd build && cmake .. -DENABLE_DCTDECODER=libjpeg -DHAVE_CAIRO=off -DENABLE_LIBOPENJPEG=none -DENABLE_CMS=none -DENABLE_LIBCURL=off -DENABLE_ZLIB=off -DENABLE_ZLIB_UNCOMPRESS=off -DENABLE_NSS3=off -DENABLE_LIBPNG=off -DENABLE_LIBTIFF=off -DENABLE_SPLASH=off -DENABLE_UTILS=off -DENABLE_CPP=off -DENABLE_GLIB=off -DENABLE_GOBJECT_INTROSPECTION=off -DENABLE_GTK_DOC=off -DENABLE_QT5=off
+
+manually disabled these because cmake failed to do it:
+HAVE_CAIRO
+ENABLE_NSS3
+ENABLE_LIBPNG (twice!)
+ENABLE_LIBTIFF (twice!)
+ENABLE_LIBCURL
+
+diff --git a/config.h b/config.h
+new file mode 100644
+index 0fbd336a..451213f8 100644
+--- /dev/null
++++ b/config.h
+@@ -0,0 +1,248 @@
++/* config.h.  Generated from config.h.cmake by cmake.  */
++
++/* Build against libcurl. */
++/* #undef ENABLE_LIBCURL */
++
++/* Use libjpeg instead of builtin jpeg decoder. */
++#define ENABLE_LIBJPEG 1
++
++/* Use libopenjpeg instead of builtin jpeg2000 decoder. */
++/* #undef ENABLE_LIBOPENJPEG */
++
++/* Build against libtiff. */
++/* #define ENABLE_LIBTIFF 1 */
++
++/* Build against libpng. */
++/* #define ENABLE_LIBPNG 1 */
++
++/* Do not hardcode the library location */
++/* #undef ENABLE_RELOCATABLE */
++
++/* Build against zlib. */
++/* #undef ENABLE_ZLIB */
++
++/* Use zlib instead of builtin zlib decoder to uncompress flate streams. */
++/* #undef ENABLE_ZLIB_UNCOMPRESS */
++
++/* Build against libnss3 for digital signature validation */
++/* #define ENABLE_NSS3 1 */
++
++/* Use cairo for rendering. */
++/* #define HAVE_CAIRO 1 */
++
++/* Do we have any DCT decoder?. */
++#define HAVE_DCT_DECODER 1
++
++/* Do we have any JPX decoder?. */
++/* #undef HAVE_JPX_DECODER */
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
++   */
++#define HAVE_DIRENT_H 1
++#endif
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the <dlfcn.h> header file. */
++#define HAVE_DLFCN_H 1
++#endif
++
++/* Define to 1 if you have the <fcntl.h> header file. */
++#define HAVE_FCNTL_H 1
++
++/* Define to 1 if you have the `fseek64' function. */
++/* #undef HAVE_FSEEK64 */
++
++#if !defined(_WIN32)
++/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
++#define HAVE_FSEEKO 1
++#endif
++
++/* Define to 1 if you have the `ftell64' function. */
++/* #undef HAVE_FTELL64 */
++
++#if !defined(__APPLE__) && !defined(_WIN32)
++/* Define to 1 if you have the `pread64' function. */
++#define HAVE_PREAD64 1
++#endif
++
++#if !defined(__APPLE__) && !defined(_WIN32)
++/* Define to 1 if you have the `lseek64' function. */
++#define HAVE_LSEEK64 1
++#endif
++
++#if !defined(_WIN32)
++/* Defines if gettimeofday is available on your system */
++#define HAVE_GETTIMEOFDAY 1
++#endif
++
++#if !defined(_WIN32)
++/* Defines if gmtime_r is available on your system */
++#define HAVE_GMTIME_R 1
++#endif
++
++#if !defined(_WIN32)
++/* Defines if timegm is available on your system */
++#define HAVE_TIMEGM 1
++#endif
++
++/* Define if you have the iconv() function and it works. */
++/* #undef HAVE_ICONV */
++
++/* Define to 1 if you have the `z' library (-lz). */
++/* #undef HAVE_LIBZ */
++
++#if !defined(_WIN32)
++/* Defines if localtime_r is available on your system */
++#define HAVE_LOCALTIME_R 1
++#endif
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the `mkstemp' function. */
++#define HAVE_MKSTEMP 1
++#endif
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the `rand_r' function. */
++#define HAVE_RAND_R 1
++#endif
++
++#if defined(_WIN32)
++/* Define to 1 if you have the `strcpy_s' function. */
++#define HAVE_STRCPY_S 1
++#endif
++
++#if defined(_WIN32)
++/* Define to 1 if you have the `strcat_s' function. */
++#define HAVE_STRCAT_S 1
++#endif
++
++#if !defined(_WIN32)
++/* Defines if strtok_r is available on your system */
++#define HAVE_STRTOK_R 1
++#endif
++
++/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
++/* #undef HAVE_NDIR_H */
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the `popen' function. */
++#define HAVE_POPEN 1
++#endif
++
++/* Use splash for rendering. */
++/* #undef HAVE_SPLASH */
++
++#if !defined(__APPLE__) && !defined(_WIN32)
++/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
++   */
++#define HAVE_SYS_DIR_H 1
++#endif
++
++#if !defined(__APPLE__) && !defined(_WIN32)
++/* Define to 1 if you have the <sys/mman.h> header file. */
++#define HAVE_SYS_MMAN_H 1
++#endif
++
++/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
++   */
++/* #undef HAVE_SYS_NDIR_H */
++
++/* Define to 1 if you have the <sys/stat.h> header file. */
++#define HAVE_SYS_STAT_H 1
++
++#if !defined(_WIN32)
++/* Define to 1 if you have the <unistd.h> header file. */
++#define HAVE_UNISTD_H 1
++#endif
++
++/* Define to 1 if you have a big endian machine */
++/* #undef WORDS_BIGENDIAN */
++
++/* Define as const if the declaration of iconv() needs const. */
++#define ICONV_CONST 
++
++/* Enable multithreading support. */
++#define MULTITHREADED 1
++
++/* Generate OPI comments in PS output. */
++#define OPI_SUPPORT 1
++
++/* Name of package */
++#define PACKAGE "poppler"
++
++/* Define to the address where bug reports for this package should be sent. */
++#define PACKAGE_BUGREPORT "https://bugs.freedesktop.org/enter_bug.cgi?product=poppler"
++
++/* Define to the full name of this package. */
++#define PACKAGE_NAME "poppler"
++
++/* Define to the full name and version of this package. */
++#define PACKAGE_STRING "poppler 0.66.0"
++
++/* Define to the one symbol short name of this package. */
++#define PACKAGE_TARNAME "poppler"
++
++/* Define to the home page for this package. */
++#define PACKAGE_URL ""
++
++/* Define to the version of this package. */
++#define PACKAGE_VERSION "0.66.0"
++
++/* Poppler data dir */
++#define POPPLER_DATADIR "/usr/local/share/poppler"
++
++/* Support for curl based doc builder is compiled in. */
++/* #undef POPPLER_HAS_CURL_SUPPORT */
++
++/* Include support for CMYK rasterization */
++/* #undef SPLASH_CMYK */
++
++/* Enable word list support. */
++#define TEXTOUT_WORD_LIST 1
++
++/* Defines if use cms */
++/* #undef USE_CMS */
++
++/* Use fixed point arithmetic in the Splash backend */
++/* #undef USE_FIXEDPOINT */
++
++/* Use single precision arithmetic in the Splash backend */
++/* #undef USE_FLOAT */
++
++/* Version number of package */
++#define VERSION "0.66.0"
++
++#if defined(__APPLE__)
++#elif defined (_WIN32)
++/* Use win32 font configuration backend */
++#define WITH_FONTCONFIGURATION_WIN32 1
++#else
++/* Use fontconfig font configuration backend */
++#define WITH_FONTCONFIGURATION_FONTCONFIG 1
++#endif
++
++/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag */
++/* #undef WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG */
++
++/* MS defined snprintf as deprecated but then added it in Visual Studio 2015. */
++#if defined(_MSC_VER) && _MSC_VER < 1900
++#define snprintf _snprintf
++#endif
++
++//------------------------------------------------------------------------
++// popen
++//------------------------------------------------------------------------
++#if defined(_MSC_VER) || defined(__BORLANDC__)
++#define popen _popen
++#define pclose _pclose
++#endif
++
++/* Number of bits in a file offset, on hosts where this is settable. */
++/* #undef _FILE_OFFSET_BITS */
++
++/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
++/* TODO This is wrong, port if needed #undef _LARGEFILE_SOURCE */
++
++/* Define for large files, on AIX-style hosts. */
++/* TODO This is wrong, port if needed #undef _LARGE_FILES */
+diff --git a/poppler/poppler-config.h b/poppler/poppler-config.h
+new file mode 100644
+index 0fbd336a..451213f8 100644
+--- /dev/null
++++ b/poppler/poppler-config.h
+@@ -0,0 +1,168 @@
++//================================================= -*- mode: c++ -*- ====
++//
++// poppler-config.h
++//
++// Copyright 1996-2011 Glyph & Cog, LLC
++//
++//========================================================================
++
++//========================================================================
++//
++// Modified under the Poppler project - http://poppler.freedesktop.org
++//
++// All changes made under the Poppler project to this file are licensed
++// under GPL version 2 or later
++//
++// Copyright (C) 2014 Bogdan Cristea <cristeab at gmail.com>
++// Copyright (C) 2014 Hib Eris <hib at hiberis.nl>
++// Copyright (C) 2016 Tor Lillqvist <tml at collabora.com>
++// Copyright (C) 2017 Adrian Johnson <ajohnson at redneon.com>
++//
++// To see a description of the changes please see the Changelog file that
++// came with your tarball or type make ChangeLog if you are building from git
++//
++//========================================================================
++
++#ifndef POPPLER_CONFIG_H
++#define POPPLER_CONFIG_H
++
++// We duplicate some of the config.h #define's here since they are
++// used in some of the header files we install.  The #ifndef/#endif
++// around #undef look odd, but it's to silence warnings about
++// redefining those symbols.
++
++/* Defines the poppler version. */
++#ifndef POPPLER_VERSION
++#define POPPLER_VERSION "0.66.0"
++#endif
++
++/* Enable multithreading support. */
++#ifndef MULTITHREADED
++#define MULTITHREADED 1
++#endif
++
++/* Use fixedpoint. */
++#ifndef USE_FIXEDPOINT
++/* #undef USE_FIXEDPOINT */
++#endif
++
++/* Use single precision arithmetic in the Splash backend */
++#ifndef USE_FLOAT
++/* #undef USE_FLOAT */
++#endif
++
++/* Include support for OPI comments. */
++#ifndef OPI_SUPPORT
++#define OPI_SUPPORT 1
++#endif
++
++/* Enable word list support. */
++#ifndef TEXTOUT_WORD_LIST
++#define TEXTOUT_WORD_LIST 1
++#endif
++
++/* Support for curl is compiled in. */
++#ifndef POPPLER_HAS_CURL_SUPPORT
++/* #undef POPPLER_HAS_CURL_SUPPORT */
++#endif
++
++/* Use libjpeg instead of builtin jpeg decoder. */
++#ifndef ENABLE_LIBJPEG
++#define ENABLE_LIBJPEG 1
++#endif
++
++/* Build against libtiff. */
++#ifndef ENABLE_LIBTIFF
++/* #define ENABLE_LIBTIFF 1 */
++#endif
++
++/* Build against libpng. */
++#ifndef ENABLE_LIBPNG
++/* #define ENABLE_LIBPNG 1 */
++#endif
++
++/* Use zlib instead of builtin zlib decoder. */
++#ifndef ENABLE_ZLIB
++/* #undef ENABLE_ZLIB */
++#endif
++
++/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
++   */
++#ifndef HAVE_DIRENT_H
++#if !defined(_WIN32)
++#define HAVE_DIRENT_H 1
++#endif
++#endif
++
++/* Defines if gettimeofday is available on your system */
++#ifndef HAVE_GETTIMEOFDAY
++#if !defined(_WIN32)
++#define HAVE_GETTIMEOFDAY 1
++#endif
++#endif
++
++/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
++#ifndef HAVE_NDIR_H
++/* #undef HAVE_NDIR_H */
++#endif
++
++/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
++   */
++#ifndef HAVE_SYS_DIR_H
++#if !defined(__APPLE__) && !defined(_WIN32)
++#define HAVE_SYS_DIR_H 1
++#endif
++#endif
++
++/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
++   */
++#ifndef HAVE_SYS_NDIR_H
++/* #undef HAVE_SYS_NDIR_H */
++#endif
++
++/* Defines if use cms */
++#ifndef USE_CMS
++/* #undef USE_CMS */
++#endif
++
++// Also, there are preprocessor symbols in the header files
++// that are used but never defined when building poppler using configure
++// or cmake: DISABLE_OUTLINE, DEBUG_MEM,
++// ENABLE_PLUGINS, DEBUG_FORMS
++
++//------------------------------------------------------------------------
++// version
++//------------------------------------------------------------------------
++
++// copyright notice
++#define popplerCopyright "Copyright 2005-2018 The Poppler Developers - http://poppler.freedesktop.org"
++#define xpdfCopyright "Copyright 1996-2011 Glyph & Cog, LLC"
++
++//------------------------------------------------------------------------
++// Win32 stuff
++//------------------------------------------------------------------------
++
++#if defined(_WIN32) && !defined(_MSC_VER)
++#include <windef.h>
++#else
++#define CDECL
++#endif
++
++//------------------------------------------------------------------------
++// Compiler
++//------------------------------------------------------------------------
++
++#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
++#include <stdio.h> // __MINGW_PRINTF_FORMAT is defined in the mingw stdio.h
++#ifdef __MINGW_PRINTF_FORMAT
++#define GCC_PRINTF_FORMAT(fmt_index, va_index) \
++	__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
++#else
++#define GCC_PRINTF_FORMAT(fmt_index, va_index) \
++	__attribute__((__format__(__printf__, fmt_index, va_index)))
++#endif
++#else
++#define GCC_PRINTF_FORMAT(fmt_index, va_index)
++#endif
++
++#endif /* POPPLER_CONFIG_H */
+diff --git a/cpp/poppler-version.h b/cpp/poppler-version.h
+new file mode 100644
+index 0fbd336a..451213f8 100644
+--- /dev/null
++++ b/cpp/poppler-version.h
+@@ -0,0 +1,39 @@
++/*
++ * Copyright (C) 2009, Pino Toscano <pino at kde.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
++ */
++
++#ifndef POPPLER_VERSION_H
++#define POPPLER_VERSION_H
++
++#include "poppler-global.h"
++
++#define POPPLER_VERSION "0.66.0"
++#define POPPLER_VERSION_MAJOR 0
++#define POPPLER_VERSION_MINOR 66
++#define POPPLER_VERSION_MICRO 0
++
++namespace poppler
++{
++
++POPPLER_CPP_EXPORT std::string version_string();
++POPPLER_CPP_EXPORT unsigned int version_major();
++POPPLER_CPP_EXPORT unsigned int version_minor();
++POPPLER_CPP_EXPORT unsigned int version_micro();
++
++}
++
++#endif
diff --git a/external/poppler/poppler-libjpeg.patch.1 b/external/poppler/poppler-libjpeg.patch.1
deleted file mode 100644
index c8d54beb75ae..000000000000
--- a/external/poppler/poppler-libjpeg.patch.1
+++ /dev/null
@@ -1,23 +0,0 @@
-do not override user supplied LIBJPEG_LIBS so we can use the one in WORKDIR
-
---- poppler/configure.orig	2016-11-02 13:58:32.530617038 +0100
-+++ poppler/configure	2016-11-02 13:58:06.233617689 +0100
-@@ -21377,8 +21377,9 @@
-           ac_save_USER_INCLUDES="$USER_INCLUDES"
-   ac_save_USER_LDFLAGS="$USER_LDFLAGS"
-   USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS"
--  USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS"
-+  USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_LIBS"
- 
-+if test -z "$LIBJPEG_LIBS"; then
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg6b" >&5
- $as_echo_n "checking for libjpeg6b... " >&6; }
-@@ -21489,6 +21490,7 @@
- 
- 
- fi
-+fi
- 
- 
- ac_save_CPPFLAGS="$CPPFLAGS"
diff --git a/external/poppler/poppler-mac-fake.patch.1 b/external/poppler/poppler-mac-fake.patch.1
deleted file mode 100644
index d0b1936658ca..000000000000
--- a/external/poppler/poppler-mac-fake.patch.1
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -ur poppler.org/poppler/GlobalParams.cc poppler/poppler/GlobalParams.cc
---- poppler.org/poppler/GlobalParams.cc	2013-07-09 06:24:38.000000000 -0500
-+++ poppler/poppler/GlobalParams.cc	2013-07-09 06:25:18.000000000 -0500
-@@ -1327,7 +1327,7 @@
-   return path;
- }
- 
--#elif WITH_FONTCONFIGURATION_WIN32
-+#elif WITH_FONTCONFIGURATION_WIN32 && defined(_WIN32)
- #include "GlobalParamsWin.cc"
- 
- GooString *GlobalParams::findBase14FontFile(GooString *base14Name, GfxFont *font) {
-
diff --git a/external/poppler/poppler-notests.patch.1 b/external/poppler/poppler-notests.patch.1
deleted file mode 100644
index ffac17312959..000000000000
--- a/external/poppler/poppler-notests.patch.1
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -483,7 +483,7 @@
- @BUILD_POPPLER_QT4_TRUE at qt4_pc_file = poppler-qt4.pc
- @BUILD_POPPLER_CPP_TRUE at cpp_subdir = cpp
- @BUILD_POPPLER_CPP_TRUE at cpp_pc_file = poppler-cpp.pc
--SUBDIRS = goo fofi $(splash_subdir) poppler utils $(glib_subdir) test $(qt4_subdir) $(qt5_subdir) $(cpp_subdir)
-+SUBDIRS = goo fofi $(splash_subdir) poppler utils $(glib_subdir) $(qt4_subdir) $(qt5_subdir) $(cpp_subdir)
- 
- # Add CMake buildsystem files here so they get added on make dist
- EXTRA_DIST = README-XPDF poppler.pc.in poppler-uninstalled.pc.in \
diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
deleted file mode 100644
index f6e4667dc133..000000000000
--- a/external/poppler/ubsan.patch.0
+++ /dev/null
@@ -1,230 +0,0 @@
---- poppler/Form.cc
-+++ poppler/Form.cc
-@@ -463,12 +463,11 @@
- // FormField
- //========================================================================
- 
--FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parentA, std::set<int> *usedParents, FormFieldType ty)
-+FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parentA, FormFieldType ty)
- {
-   doc = docA;
-   xref = doc->getXRef();
-   obj = aobj->copy();
--  Dict* dict = obj.getDict();
-   ref.num = ref.gen = 0;
-   type = ty;
-   parent = parentA;
-@@ -483,7 +482,11 @@
-   hasQuadding = gFalse;
- 
-   ref = aref;
-+}
- 
-+void FormField::init(std::set<int> *usedParents)
-+{
-+  Dict* dict = obj.getDict();
-   //childs
-   Object obj1 = dict->lookup("Kids");
-   if (obj1.isArray()) {
-@@ -803,9 +806,15 @@
- //------------------------------------------------------------------------
- // FormFieldButton
- //------------------------------------------------------------------------
--FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
--  : FormField(docA, aobj, ref, parent, usedParents, formButton)
-+FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
-+  : FormField(docA, aobj, ref, parent, formButton)
- {
-+}
-+
-+void FormFieldButton::init(std::set<int> *usedParents)
-+{
-+  FormField::init(usedParents);
-+
-   Dict* dict = obj.getDict();
-   active_child = -1;
-   noAllOff = false;
-@@ -983,9 +992,15 @@
- //------------------------------------------------------------------------
- // FormFieldText
- //------------------------------------------------------------------------
--FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
--  : FormField(docA, aobj, ref, parent, usedParents, formText)
-+FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
-+  : FormField(docA, aobj, ref, parent, formText)
- {
-+}
-+
-+void FormFieldText::init(std::set<int> *usedParents)
-+{
-+  FormField::init(usedParents);
-+
-   Dict* dict = obj.getDict();
-   Object obj1;
-   content = NULL;
-@@ -1076,9 +1091,15 @@
- //------------------------------------------------------------------------
- // FormFieldChoice
- //------------------------------------------------------------------------
--FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
--  : FormField(docA, aobj, ref, parent, usedParents, formChoice)
-+FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
-+  : FormField(docA, aobj, ref, parent, formChoice)
- {
-+}
-+
-+void FormFieldChoice::init(std::set<int> *usedParents)
-+{
-+  FormField::init(usedParents);
-+
-   numChoices = 0;
-   choices = NULL;
-   editedChoice = NULL;
-@@ -1379,11 +1400,17 @@
- //------------------------------------------------------------------------
- // FormFieldSignature
- //------------------------------------------------------------------------
--FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
--  : FormField(docA, dict, ref, parent, usedParents, formSignature),
-+FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent)
-+  : FormField(docA, dict, ref, parent, formSignature),
-     signature_type(adbe_pkcs7_detached),
-     signature(nullptr), signature_info(nullptr)
- {
-+}
-+
-+void FormFieldSignature::init(std::set<int> *usedParents)
-+{
-+  FormField::init(usedParents);
-+
-   signature = NULL;
- 
-   signature_info = new SignatureInfo();
-@@ -1691,15 +1718,15 @@
- 
-     Object obj2 = Form::fieldLookup(obj->getDict (), "FT");
-     if (obj2.isName("Btn")) {
--      field = new FormFieldButton(docA, obj, pref, parent, usedParents);
-+      field = FormFieldButton::create(docA, obj, pref, parent, usedParents);
-     } else if (obj2.isName("Tx")) {
--      field = new FormFieldText(docA, obj, pref, parent, usedParents);
-+      field = FormFieldText::create(docA, obj, pref, parent, usedParents);
-     } else if (obj2.isName("Ch")) {
--      field = new FormFieldChoice(docA, obj, pref, parent, usedParents);
-+      field = FormFieldChoice::create(docA, obj, pref, parent, usedParents);
-     } else if (obj2.isName("Sig")) {
--      field = new FormFieldSignature(docA, obj, pref, parent, usedParents);
-+      field = FormFieldSignature::create(docA, obj, pref, parent, usedParents);
-     } else { //we don't have an FT entry => non-terminal field
--      field = new FormField(docA, obj, pref, parent, usedParents);
-+      field = FormField::create(docA, obj, pref, parent, usedParents);
-     }
- 
-     return field;
---- poppler/Form.h
-+++ poppler/Form.h
-@@ -264,8 +264,16 @@
- //------------------------------------------------------------------------
- 
- class FormField {
--public:
--  FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef);
-+protected:
-+  FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, FormFieldType t);
-+  void init(std::set<int> *usedParents);
-+public:
-+  static FormField *create(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef)
-+  {
-+    FormField *f = new FormField(docA, aobj, aref, parent, t);
-+    f->init(usedParents);
-+    return f;
-+  }
- 
-   virtual ~FormField();
- 
-@@ -338,8 +346,16 @@
- //------------------------------------------------------------------------
- 
- class FormFieldButton: public FormField {
--public:
--  FormFieldButton(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
-+private:
-+  FormFieldButton(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
-+  void init(std::set<int> *usedParents);
-+public:
-+  static FormFieldButton *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
-+  {
-+    FormFieldButton *f = new FormFieldButton(docA, dict, ref, parent);
-+    f->init(usedParents);
-+    return f;
-+  }
- 
-   FormButtonType getButtonType () { return btype; }
- 
-@@ -384,8 +400,16 @@
- //------------------------------------------------------------------------
- 
- class FormFieldText: public FormField {
--public:
--  FormFieldText(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
-+private:
-+  FormFieldText(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
-+  void init(std::set<int> *usedParents);
-+public:
-+  static FormFieldText *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
-+  {
-+    FormFieldText *f = new FormFieldText(docA, dict, ref, parent);
-+    f->init(usedParents);
-+    return f;
-+  }
-   
-   GooString* getContent () { return content; }
-   GooString* getContentCopy ();
-@@ -422,8 +446,16 @@
- //------------------------------------------------------------------------
- 
- class FormFieldChoice: public FormField {
--public:
--  FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents);
-+private:
-+  FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent);
-+  void init(std::set<int> *usedParents);
-+public:
-+  static FormFieldChoice *create(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
-+  {
-+    FormFieldChoice *f = new FormFieldChoice(docA, aobj, ref, parent);
-+    f->init(usedParents);
-+    return f;
-+  }
- 
-   ~FormFieldChoice();
- 
-@@ -491,8 +523,16 @@
- 
- class FormFieldSignature: public FormField {
-   friend class FormWidgetSignature;
--public:
--  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
-+private:
-+  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
-+  void init(std::set<int> *usedParents);
-+public:
-+  static FormFieldSignature *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
-+  {
-+    FormFieldSignature *f = new FormFieldSignature(docA, dict, ref, parent);
-+    f->init(usedParents);
-+    return f;
-+  }
- 
-   // Use -1 for now as validationTime
-   SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime);
---- poppler/XRef.cc
-+++ poppler/XRef.cc
-@@ -293,6 +293,7 @@
-   xRefStream = gFalse;
-   scannedSpecialFlags = gFalse;
-   encrypted = gFalse;
-+  encAlgorithm = cryptRC4;
-   permFlags = defPermFlags;
-   ownerPasswordOk = gFalse;
-   rootNum = -1;
commit b21a87eebf8b72a70ec7788d883cd75e485a2eca
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Sep 7 15:50:09 2017 +0200

    upload poppler 0.59.0
    
    Change-Id: I21dfa3aa04bd960cb2fb87a53213ae4bbd510a24
    Reviewed-on: https://gerrit.libreoffice.org/42061
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 1c983335116a6f09cabf0b3eae7f51951111341e)
    Reviewed-on: https://gerrit.libreoffice.org/56256
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/download.lst b/download.lst
index ccd5e8b3b1bd..5677ab58e433 100644
--- a/download.lst
+++ b/download.lst
@@ -129,8 +129,8 @@ export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
 export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
 export PNG_TARBALL := libpng-1.6.28.tar.gz
-export POPPLER_MD5SUM := f7a8230626b6d2061acfdc852930b7dd
-export POPPLER_TARBALL := poppler-0.55.0.tar.xz
+export POPPLER_MD5SUM := 6e44408a3b4f4a738f8a6770d0aea8a5
+export POPPLER_TARBALL := poppler-0.59.0.tar.xz
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 
 ifeq ($(PYTHON_VERSION_MINOR),3)
diff --git a/external/poppler/0001-Fix-building-with-old-clang.patch.1 b/external/poppler/0001-Fix-building-with-old-clang.patch.1
new file mode 100644
index 000000000000..dcddd11d2967
--- /dev/null
+++ b/external/poppler/0001-Fix-building-with-old-clang.patch.1
@@ -0,0 +1,25 @@
+From dd80c182cbcb188af0dd590f222ba9bbb31e3fb7 Mon Sep 17 00:00:00 2001
+From: Albert Astals Cid <aacid at kde.org>
+Date: Mon, 4 Sep 2017 19:36:06 +0200
+Subject: [PATCH] Fix building with old clang
+
+---
+ poppler/StructElement.cc | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
+index 0fbd336a..451213f8 100644
+--- a/poppler/StructElement.cc
++++ b/poppler/StructElement.cc
+@@ -248,6 +248,8 @@ struct AttributeMapEntry {
+ };
+ 
+ struct AttributeDefaults {
++  AttributeDefaults() {}; // needed to support old clang
++
+   Object Inline  = Object(objName, "Inline");
+   Object LrTb = Object(objName, "LrTb");
+   Object Normal = Object(objName, "Normal");
+-- 
+2.13.5
+
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index f72c040c513b..94c8eb650dbc 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
 	external/poppler/poppler-mac-fake.patch.1 \
 	external/poppler/ubsan.patch.0 \
 	external/poppler/poppler-libjpeg.patch.1 \
+	external/poppler/0001-Fix-building-with-old-clang.patch.1 \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
index e0bf164ce7fc..f6e4667dc133 100644
--- a/external/poppler/ubsan.patch.0
+++ b/external/poppler/ubsan.patch.0
@@ -9,7 +9,7 @@
  {
    doc = docA;
    xref = doc->getXRef();
-   aobj->copy(&obj);
+   obj = aobj->copy();
 -  Dict* dict = obj.getDict();
    ref.num = ref.gen = 0;
    type = ty;
@@ -23,9 +23,9 @@
 +void FormField::init(std::set<int> *usedParents)
 +{
 +  Dict* dict = obj.getDict();
-   Object obj1;
    //childs
-   if (dict->lookup("Kids", &obj1)->isArray()) {
+   Object obj1 = dict->lookup("Kids");
+   if (obj1.isArray()) {
 @@ -803,9 +806,15 @@
  //------------------------------------------------------------------------
  // FormFieldButton
@@ -80,14 +80,16 @@
    numChoices = 0;
    choices = NULL;
    editedChoice = NULL;
-@@ -1379,9 +1400,15 @@
+@@ -1379,11 +1400,17 @@
  //------------------------------------------------------------------------
  // FormFieldSignature
  //------------------------------------------------------------------------
 -FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
--  : FormField(docA, dict, ref, parent, usedParents, formSignature)
+-  : FormField(docA, dict, ref, parent, usedParents, formSignature),
 +FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent)
-+  : FormField(docA, dict, ref, parent, formSignature)
++  : FormField(docA, dict, ref, parent, formSignature),
+     signature_type(adbe_pkcs7_detached),
+     signature(nullptr), signature_info(nullptr)
  {
 +}
 +
@@ -99,9 +101,9 @@
  
    signature_info = new SignatureInfo();
 @@ -1691,15 +1718,15 @@
-     FormField *field;
  
-     if (Form::fieldLookup(obj->getDict (), "FT", &obj2)->isName("Btn")) {
+     Object obj2 = Form::fieldLookup(obj->getDict (), "FT");
+     if (obj2.isName("Btn")) {
 -      field = new FormFieldButton(docA, obj, pref, parent, usedParents);
 +      field = FormFieldButton::create(docA, obj, pref, parent, usedParents);
      } else if (obj2.isName("Tx")) {
@@ -117,8 +119,8 @@
 -      field = new FormField(docA, obj, pref, parent, usedParents);
 +      field = FormField::create(docA, obj, pref, parent, usedParents);
      }
-     obj2.free();
  
+     return field;
 --- poppler/Form.h
 +++ poppler/Form.h
 @@ -264,8 +264,16 @@
@@ -198,9 +200,9 @@
    ~FormFieldChoice();
  
 @@ -491,8 +523,16 @@
- //------------------------------------------------------------------------
  
  class FormFieldSignature: public FormField {
+   friend class FormWidgetSignature;
 -public:
 -  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
 +private:
@@ -214,8 +216,8 @@
 +    return f;
 +  }
  
-   SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation);
- 
+   // Use -1 for now as validationTime
+   SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime);
 --- poppler/XRef.cc
 +++ poppler/XRef.cc
 @@ -293,6 +293,7 @@
commit 135a80337da4549df6b0a5c14ad38e9edc0680f3
Author: David Tardon <dtardon at redhat.com>
Date:   Wed May 24 19:09:54 2017 +0200

    upload poppler 0.55.0
    
    Change-Id: I19b7d324a2dc50d006b4d255ddb6a5c1f15bc616
    Reviewed-on: https://gerrit.libreoffice.org/37998
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit b12e16f8fc186117cbb20cc3866bf052a3d75515)
    Signed-off-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 51775f495f0399177edbcabb2ad881cdd9f57e0f)
    Reviewed-on: https://gerrit.libreoffice.org/56255
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/download.lst b/download.lst
index 18681926e860..ccd5e8b3b1bd 100644
--- a/download.lst
+++ b/download.lst
@@ -129,8 +129,8 @@ export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
 export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
 export PNG_TARBALL := libpng-1.6.28.tar.gz
-export POPPLER_MD5SUM := 9e057ed8eee1f9979fa75d8f044783b8
-export POPPLER_TARBALL := poppler-0.49.0.tar.xz
+export POPPLER_MD5SUM := f7a8230626b6d2061acfdc852930b7dd
+export POPPLER_TARBALL := poppler-0.55.0.tar.xz
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 
 ifeq ($(PYTHON_VERSION_MINOR),3)
diff --git a/external/poppler/ExternalProject_poppler.mk b/external/poppler/ExternalProject_poppler.mk
index 2a83b164ce4d..83d51b9ea9e7 100644
--- a/external/poppler/ExternalProject_poppler.mk
+++ b/external/poppler/ExternalProject_poppler.mk
@@ -28,7 +28,7 @@ $(call gb_ExternalProject_get_state_target,poppler,build) :
 			--disable-shared \
 			--enable-xpdf-headers \
 			--disable-poppler-cpp \
-			--disable-libopenjpeg \
+			--enable-libopenjpeg=none \
 			--disable-libtiff \
 			--enable-libjpeg \
 			--disable-libpng \
diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
index 67675253b5ad..e0bf164ce7fc 100644
--- a/external/poppler/ubsan.patch.0
+++ b/external/poppler/ubsan.patch.0
@@ -195,7 +195,7 @@
 +    return f;
 +  }
  
-   virtual ~FormFieldChoice();
+   ~FormFieldChoice();
  
 @@ -491,8 +523,16 @@
  //------------------------------------------------------------------------
commit 9c458cb6de652edd48b84b25ccb22dab1b0b4f22
Author: David Tardon <dtardon at redhat.com>
Date:   Wed Nov 23 13:47:52 2016 +0100

    upload poppler 0.49.0
    
    Change-Id: I98508a1a2b57c7b39d5be3bf216271001b6a0427
    Reviewed-on: https://gerrit.libreoffice.org/31111
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 6f1ae11761ddfa2f928254ff51f1860155f670a4)
    Signed-off-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit b1d30ac04e95e72883c759110df6d5e46ce94510)
    Reviewed-on: https://gerrit.libreoffice.org/56254
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/download.lst b/download.lst
index 958ed3048252..18681926e860 100644
--- a/download.lst
+++ b/download.lst
@@ -129,8 +129,8 @@ export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
 export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
 export PNG_TARBALL := libpng-1.6.28.tar.gz
-export POPPLER_MD5SUM := 8d61c91cb9e99ad38bba1b0b4432f174
-export POPPLER_TARBALL := poppler-0.48.0.tar.xz
+export POPPLER_MD5SUM := 9e057ed8eee1f9979fa75d8f044783b8
+export POPPLER_TARBALL := poppler-0.49.0.tar.xz
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 
 ifeq ($(PYTHON_VERSION_MINOR),3)
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index afad5fba13b6..f72c040c513b 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -15,8 +15,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
 	external/poppler/poppler-notests.patch.1 \
 	$(if $(filter MSC-120,$(COM)-$(VCVER)),external/poppler/poppler-snprintf.patch.1) \
 	external/poppler/poppler-mac-fake.patch.1 \
-	external/poppler/poppler-vs2013.patch.1 \
-	external/poppler/poppler-0.46.0-std-max.patch.1 \
 	external/poppler/ubsan.patch.0 \
 	external/poppler/poppler-libjpeg.patch.1 \
 ))
diff --git a/external/poppler/poppler-0.46.0-std-max.patch.1 b/external/poppler/poppler-0.46.0-std-max.patch.1
deleted file mode 100644
index 96a9abe88695..000000000000
--- a/external/poppler/poppler-0.46.0-std-max.patch.1
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/poppler/PSOutputDev.cc
-+++ b/poppler/PSOutputDev.cc
-@@ -48,6 +48,7 @@
- #include <signal.h>
- #include <math.h>
- #include <limits.h>
-+#include <algorithm>
- #include "goo/GooString.h"
- #include "goo/GooList.h"
- #include "goo/GooHash.h"
diff --git a/external/poppler/poppler-vs2013.patch.1 b/external/poppler/poppler-vs2013.patch.1
deleted file mode 100644
index ca892dfc2500..000000000000
--- a/external/poppler/poppler-vs2013.patch.1
+++ /dev/null
@@ -1,11 +0,0 @@
---- poppler/poppler/poppler-config.h.in
-+++ poppler/poppler/poppler-config.h.in
-@@ -186,7 +186,7 @@ char * strtok_r (char *s, const char *delim, char **save_ptr);
- #define GCC_PRINTF_FORMAT(fmt_index, va_index)
- #endif
- 
--#if defined(_MSC_VER)
-+#if defined(_MSC_VER) && _MSC_VER < 1800
- #define fmax(a, b) std::max(a, b)
- #define fmin(a, b) std::min(a, b)
- #endif
commit ae00e06b99d66fdf5306e73df8f85397fa0ab7c3
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Nov 3 11:13:29 2016 +0100

    poppler: remove obsolete ubsan patch hunk
    
    With eea709f67d91e271e3df37e6c6724b7b5870b1ee "poppler: build against
    libjpeg" the poppler internal JPEG code is no longer used.
    
    Change-Id: I018a53a495ec505af92bb9b1c1a0c42e0a4f35b8
    (cherry picked from commit 21ca0db5ec27662a3e047d7547eae9beb87b0b01)
    Reviewed-on: https://gerrit.libreoffice.org/56253
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
index 575cb47dc682..67675253b5ad 100644
--- a/external/poppler/ubsan.patch.0
+++ b/external/poppler/ubsan.patch.0
@@ -216,43 +216,6 @@
  
    SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation);
  
---- poppler/Stream.cc
-+++ poppler/Stream.cc
-@@ -2966,12 +2966,12 @@
-       } else {
- 	amp = 0;
-       }
--      data[0] += (*prevDC += amp) << scanInfo.al;
-+      data[0] += (int) ((unsigned) (*prevDC += amp) << scanInfo.al);
-     } else {
-       if ((bit = readBit()) == 9999) {
- 	return gFalse;
-       }
--      data[0] += bit << scanInfo.al;
-+      data[0] += (unsigned) bit << scanInfo.al;
-     }
-     ++i;
-   }
-@@ -3064,7 +3064,7 @@
- 	  j = dctZigZag[i++];
- 	}
-       }
--      data[j] = amp << scanInfo.al;
-+      data[j] = (unsigned) amp << scanInfo.al;
-     }
-   }
- 
-@@ -3251,8 +3251,8 @@
-     v3 = p[6];
-     v4 = (dctSqrt1d2 * (p[1] - p[7]) + 128) >> 8;
-     v7 = (dctSqrt1d2 * (p[1] + p[7]) + 128) >> 8;
--    v5 = p[3] << 4;
--    v6 = p[5] << 4;
-+    v5 = (unsigned) p[3] << 4;
-+    v6 = (unsigned) p[5] << 4;
- 
-     // stage 3
-     t = (v0 - v1+ 1) >> 1;
 --- poppler/XRef.cc
 +++ poppler/XRef.cc
 @@ -293,6 +293,7 @@
commit 2543b42096ad1be8d744eb3c9976f30add50bbb7
Author: David Tardon <dtardon at redhat.com>
Date:   Sat Oct 22 10:16:56 2016 +0200

    upload poppler 0.48.0
    
    Change-Id: I18c49505f71ab609e5cc0e4db759152c3c1d5825
    (cherry picked from commit dc522a114d24ad7c550c072d4f29f50a62260b77)
    Reviewed-on: https://gerrit.libreoffice.org/56252
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/download.lst b/download.lst
index 42ed25265e27..958ed3048252 100644
--- a/download.lst
+++ b/download.lst
@@ -129,8 +129,8 @@ export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
 export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
 export PNG_TARBALL := libpng-1.6.28.tar.gz
-export POPPLER_MD5SUM := 38c758d84437378ec4f5aae9f875301d
-export POPPLER_TARBALL := poppler-0.46.0.tar.bz2
+export POPPLER_MD5SUM := 8d61c91cb9e99ad38bba1b0b4432f174
+export POPPLER_TARBALL := poppler-0.48.0.tar.xz
 export POSTGRESQL_TARBALL := c0b4799ea9850eae3ead14f0a60e9418-postgresql-9.2.1.tar.bz2
 
 ifeq ($(PYTHON_VERSION_MINOR),3)
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index efcbee7c7e0f..afad5fba13b6 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -17,7 +17,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
 	external/poppler/poppler-mac-fake.patch.1 \
 	external/poppler/poppler-vs2013.patch.1 \
 	external/poppler/poppler-0.46.0-std-max.patch.1 \
-	external/poppler/poppler-0.46.0-unused-private-field.patch.1 \
 	external/poppler/ubsan.patch.0 \
 	external/poppler/poppler-libjpeg.patch.1 \
 ))
diff --git a/external/poppler/poppler-0.46.0-unused-private-field.patch.1 b/external/poppler/poppler-0.46.0-unused-private-field.patch.1
deleted file mode 100644
index e0765fc92251..000000000000
--- a/external/poppler/poppler-0.46.0-unused-private-field.patch.1
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/goo/GooString.h
-+++ b/goo/GooString.h
-@@ -175,7 +175,7 @@
-   // You can tweak the final object size for different time/space tradeoffs.
-   // In libc malloc(), rounding is 16 so it's best to choose a value that
-   // is a multiple of 16.
--  class MemoryLayout {
-+  struct MemoryLayout {
-       char c[sizeof(char*)];
-       int i;
-       char* s;
diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
index a27f00f790d2..575cb47dc682 100644
--- a/external/poppler/ubsan.patch.0
+++ b/external/poppler/ubsan.patch.0
@@ -1,14 +1,3 @@
---- goo/GooString.cc
-+++ goo/GooString.cc
-@@ -161,7 +161,7 @@
-       // assert(s != s1) the roundedSize condition ensures this
-       if (newLength < length) {
- 	memcpy(s1, s, newLength);
--      } else {
-+      } else if (length != 0) {
- 	memcpy(s1, s, length);
-       }
-       if (s != sStatic)
 --- poppler/Form.cc
 +++ poppler/Form.cc
 @@ -463,12 +463,11 @@
commit cd433c539d6f3915462851f5d3f5bc8e5c600a61
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 14 15:34:53 2016 +0200

    external/poppler: Avoid UBSan warning about undefined downcast
    
    ...of this-ptr of in-construction FormFieldSignature while still in the base
    FormField ctor, as happens (in the xpdfimport process) during
    CppunitTest_xmlsecurity_signing:
    
    > Form.cc:448:12: runtime error: downcast of address 0x60f000000040 which does not point to an object of type 'FormFieldSignature'
    > 0x60f000000040: note: object is of type 'FormField'
    >  03 00 00 6d  50 84 f2 00 00 00 00 00  03 00 00 00 04 00 00 00  00 00 00 00 01 be be be  07 00 00 00
    >               ^~~~~~~~~~~~~~~~~~~~~~~
    >               vptr for 'FormField'
    >     #0 0x73d7f4 in FormWidgetSignature::FormWidgetSignature(PDFDoc*, Object*, unsigned int, Ref, FormField*) workdir/UnpackedTarball/poppler/poppler/Form.cc:448:12
    >     #1 0x741713 in FormField::_createWidget(Object*, Ref) workdir/UnpackedTarball/poppler/poppler/Form.cc:677:34
    >     #2 0x73e747 in FormField::FormField(PDFDoc*, Object*, Ref const&, FormField*, std::set<int, std::less<int>, std::allocator<int> >*, FormFieldType) workdir/UnpackedTarball/poppler/poppler/Form.cc:547:7
    >     #3 0x74ec2b in FormFieldSignature::FormFieldSignature(PDFDoc*, Object*, Ref const&, FormField*, std::set<int, std::less<int>, std::allocator<int> >*) workdir/UnpackedTarball/poppler/poppler/Form.cc:1383:5
    >     #4 0x740d7f in Form::createFieldFromDict(Object*, PDFDoc*, Ref const&, FormField*, std::set<int, std::less<int>, std::allocator<int> >*) workdir/UnpackedTarball/poppler/poppler/Form.cc:1700:19
    >     #5 0x750727 in Form::Form(PDFDoc*, Object*) workdir/UnpackedTarball/poppler/poppler/Form.cc:1623:33
    >     #6 0x71d440 in Catalog::getForm() workdir/UnpackedTarball/poppler/poppler/Catalog.cc:1042:18
    >     #7 0x708572 in Annots::createAnnot(Dict*, Object*) workdir/UnpackedTarball/poppler/poppler/Annot.cc:7218:41
    >     #8 0x70772b in Annots::Annots(PDFDoc*, int, Object*) workdir/UnpackedTarball/poppler/poppler/Annot.cc:7128:17
    >     #9 0x87f3e9 in Page::getAnnots(XRef*) workdir/UnpackedTarball/poppler/poppler/Page.cc:405:18
    >     #10 0x8814b0 in Page::displaySlice(OutputDev*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) workdir/UnpackedTarball/poppler/poppler/Page.cc:611:15
    >     #11 0x880ff6 in Page::display(OutputDev*, double, double, int, bool, bool, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) workdir/UnpackedTarball/poppler/poppler/Page.cc:521:3
    >     #12 0x88d906 in PDFDoc::displayPage(OutputDev*, int, double, double, int, bool, bool, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) workdir/UnpackedTarball/poppler/poppler/PDFDoc.cc:491:20
    >     #13 0x5d59fb in main sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx:142:14
    >     #14 0x7f11600ea730 in __libc_start_main (/lib64/libc.so.6+0x20730)
    >     #15 0x459388 in _start (instdir/program/xpdfimport+0x459388)
    
    Change-Id: Ia808919c8d2363d616feb4664f314a77b40dfbb8
    (cherry picked from commit 55013a7776a43bb18b7fb8faa1839369c3383cb7)
    Reviewed-on: https://gerrit.libreoffice.org/56251
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/external/poppler/ubsan.patch.0 b/external/poppler/ubsan.patch.0
index 623858da9f1f..a27f00f790d2 100644
--- a/external/poppler/ubsan.patch.0
+++ b/external/poppler/ubsan.patch.0
@@ -9,6 +9,224 @@
  	memcpy(s1, s, length);
        }
        if (s != sStatic)
+--- poppler/Form.cc
++++ poppler/Form.cc
+@@ -463,12 +463,11 @@
+ // FormField
+ //========================================================================
+ 
+-FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parentA, std::set<int> *usedParents, FormFieldType ty)
++FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parentA, FormFieldType ty)
+ {
+   doc = docA;
+   xref = doc->getXRef();
+   aobj->copy(&obj);
+-  Dict* dict = obj.getDict();
+   ref.num = ref.gen = 0;
+   type = ty;
+   parent = parentA;
+@@ -483,7 +482,11 @@
+   hasQuadding = gFalse;
+ 
+   ref = aref;
++}
+ 
++void FormField::init(std::set<int> *usedParents)
++{
++  Dict* dict = obj.getDict();
+   Object obj1;
+   //childs
+   if (dict->lookup("Kids", &obj1)->isArray()) {
+@@ -803,9 +806,15 @@
+ //------------------------------------------------------------------------
+ // FormFieldButton
+ //------------------------------------------------------------------------
+-FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
+-  : FormField(docA, aobj, ref, parent, usedParents, formButton)
++FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
++  : FormField(docA, aobj, ref, parent, formButton)
+ {
++}
++
++void FormFieldButton::init(std::set<int> *usedParents)
++{
++  FormField::init(usedParents);
++
+   Dict* dict = obj.getDict();
+   active_child = -1;
+   noAllOff = false;
+@@ -983,9 +992,15 @@
+ //------------------------------------------------------------------------
+ // FormFieldText
+ //------------------------------------------------------------------------
+-FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
+-  : FormField(docA, aobj, ref, parent, usedParents, formText)
++FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
++  : FormField(docA, aobj, ref, parent, formText)
+ {
++}
++
++void FormFieldText::init(std::set<int> *usedParents)
++{
++  FormField::init(usedParents);
++
+   Dict* dict = obj.getDict();
+   Object obj1;
+   content = NULL;
+@@ -1076,9 +1091,15 @@
+ //------------------------------------------------------------------------
+ // FormFieldChoice
+ //------------------------------------------------------------------------
+-FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
+-  : FormField(docA, aobj, ref, parent, usedParents, formChoice)
++FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent)
++  : FormField(docA, aobj, ref, parent, formChoice)
+ {
++}
++
++void FormFieldChoice::init(std::set<int> *usedParents)
++{
++  FormField::init(usedParents);
++
+   numChoices = 0;
+   choices = NULL;
+   editedChoice = NULL;
+@@ -1379,9 +1400,15 @@
+ //------------------------------------------------------------------------
+ // FormFieldSignature
+ //------------------------------------------------------------------------
+-FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
+-  : FormField(docA, dict, ref, parent, usedParents, formSignature)
++FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent)
++  : FormField(docA, dict, ref, parent, formSignature)
+ {
++}
++
++void FormFieldSignature::init(std::set<int> *usedParents)
++{
++  FormField::init(usedParents);
++
+   signature = NULL;
+ 
+   signature_info = new SignatureInfo();
+@@ -1691,15 +1718,15 @@
+     FormField *field;
+ 
+     if (Form::fieldLookup(obj->getDict (), "FT", &obj2)->isName("Btn")) {
+-      field = new FormFieldButton(docA, obj, pref, parent, usedParents);
++      field = FormFieldButton::create(docA, obj, pref, parent, usedParents);
+     } else if (obj2.isName("Tx")) {
+-      field = new FormFieldText(docA, obj, pref, parent, usedParents);
++      field = FormFieldText::create(docA, obj, pref, parent, usedParents);
+     } else if (obj2.isName("Ch")) {
+-      field = new FormFieldChoice(docA, obj, pref, parent, usedParents);
++      field = FormFieldChoice::create(docA, obj, pref, parent, usedParents);
+     } else if (obj2.isName("Sig")) {
+-      field = new FormFieldSignature(docA, obj, pref, parent, usedParents);
++      field = FormFieldSignature::create(docA, obj, pref, parent, usedParents);
+     } else { //we don't have an FT entry => non-terminal field
+-      field = new FormField(docA, obj, pref, parent, usedParents);
++      field = FormField::create(docA, obj, pref, parent, usedParents);
+     }
+     obj2.free();
+ 
+--- poppler/Form.h
++++ poppler/Form.h
+@@ -264,8 +264,16 @@
+ //------------------------------------------------------------------------
+ 
+ class FormField {
+-public:
+-  FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef);
++protected:
++  FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, FormFieldType t);
++  void init(std::set<int> *usedParents);
++public:
++  static FormField *create(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef)
++  {
++    FormField *f = new FormField(docA, aobj, aref, parent, t);
++    f->init(usedParents);
++    return f;
++  }
+ 
+   virtual ~FormField();
+ 
+@@ -338,8 +346,16 @@
+ //------------------------------------------------------------------------
+ 
+ class FormFieldButton: public FormField {
+-public:
+-  FormFieldButton(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
++private:
++  FormFieldButton(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
++  void init(std::set<int> *usedParents);
++public:
++  static FormFieldButton *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
++  {
++    FormFieldButton *f = new FormFieldButton(docA, dict, ref, parent);
++    f->init(usedParents);
++    return f;
++  }
+ 
+   FormButtonType getButtonType () { return btype; }
+ 
+@@ -384,8 +400,16 @@
+ //------------------------------------------------------------------------
+ 
+ class FormFieldText: public FormField {
+-public:
+-  FormFieldText(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
++private:
++  FormFieldText(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
++  void init(std::set<int> *usedParents);
++public:
++  static FormFieldText *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
++  {
++    FormFieldText *f = new FormFieldText(docA, dict, ref, parent);
++    f->init(usedParents);
++    return f;
++  }
+   
+   GooString* getContent () { return content; }
+   GooString* getContentCopy ();
+@@ -422,8 +446,16 @@
+ //------------------------------------------------------------------------
+ 
+ class FormFieldChoice: public FormField {
+-public:
+-  FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents);
++private:
++  FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent);
++  void init(std::set<int> *usedParents);
++public:
++  static FormFieldChoice *create(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents)
++  {
++    FormFieldChoice *f = new FormFieldChoice(docA, aobj, ref, parent);
++    f->init(usedParents);
++    return f;
++  }
+ 
+   virtual ~FormFieldChoice();
+ 
+@@ -491,8 +523,16 @@
+ //------------------------------------------------------------------------
+ 
+ class FormFieldSignature: public FormField {
+-public:
+-  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents);
++private:
++  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent);
++  void init(std::set<int> *usedParents);
++public:
++  static FormFieldSignature *create(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents)
++  {
++    FormFieldSignature *f = new FormFieldSignature(docA, dict, ref, parent);
++    f->init(usedParents);
++    return f;
++  }
+ 
+   SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation);
+ 
 --- poppler/Stream.cc
 +++ poppler/Stream.cc
 @@ -2966,12 +2966,12 @@
commit d91d8c927ede19e0b511cb2d7cfe127dd1195cfc
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date:   Fri Jun 29 11:20:57 2018 +0200

    Only supported MSVS version on this branch is VS2015
    
    Due to 3rd party dependencies requiring better C++11 support
    
    Change-Id: Ic603ce6567e21f809eda042e981e4dc099b64f43

diff --git a/configure.ac b/configure.ac
index 9bc526c6ed1c..3512693d23d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2063,13 +2063,6 @@ AC_ARG_WITH(doxygen,
          documentation. Not relevant in the --disable-odk case.]),
 ,with_doxygen=yes)
 
-AC_ARG_WITH(visual-studio,
-    AS_HELP_STRING([--with-visual-studio=<2013/2015>],
-        [Specify which Visual Studio version to use in case several are
-         installed. If not specified, only 2013 is detected automatically
-         because 2015 support is currently experimental.]),
-,)
-
 AC_ARG_WITH(windows-sdk,
     AS_HELP_STRING([--with-windows-sdk=<7.1(A)/8.0(A)/8.1(A)/10>],
         [Specify which Windows SDK, or "Windows Kit", version to use
@@ -3292,8 +3285,8 @@ vs_versions_to_check()
         map_vs_year_to_version "$1"
         vsversions=$vsversion
     else
-        # By default we prefer 2013/2015, in this order
-        vsversions="12.0 14.0"
+        # Only support VS2015 going forward
+        vsversions="14.0"
     fi
 }
 
commit 98fbf46c2e23772932b947db6e7812369d32e218
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Feb 21 20:08:23 2018 -0500

    Patch liborcus to avoid incorrect parsing of XML.
    
    Found by Antti Levomäki and Christian Jalio from Forcepoint.
    
    This one is not a backport from the master branch.  On the master
    branch the same fix will come from updating liborcus from 0.13.3
    to 0.13.4.
    
    (cherry picked from commit 160350de5f07024b22fb5a9b596918ccc7f22c75)
    
     Conflicts:
            external/liborcus/UnpackedTarball_liborcus.mk
    
    Reviewed-on: https://gerrit.libreoffice.org/50147
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit f25bc1254782589af5d24471599260b65558154a)
    
    Conflicts:
            external/liborcus/UnpackedTarball_liborcus.mk
    
    Change-Id: I701c5a65ff67d77767913f8d056682b9db549f84

diff --git a/external/liborcus/0001-protect-the-self-closing-xml-element-code-against-se.patch b/external/liborcus/0001-protect-the-self-closing-xml-element-code-against-se.patch
new file mode 100644
index 000000000000..990665f9c383
--- /dev/null
+++ b/external/liborcus/0001-protect-the-self-closing-xml-element-code-against-se.patch
@@ -0,0 +1,30 @@
+From 12e5d89cbd7101c61fbdf063322203a1590a0ef5 Mon Sep 17 00:00:00 2001
+From: Markus Mohrhard <markus.mohrhard at googlemail.com>
+Date: Wed, 21 Feb 2018 00:29:03 +0100
+Subject: [PATCH] protect the self-closing xml element code against
+ self-closing root elements
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Found by Antti Levomäki and Christian Jalio from Forcepoint.
+---
+ include/orcus/sax_parser.hpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/orcus/sax_parser.hpp b/include/orcus/sax_parser.hpp
+index ba5ebcd..67d5943 100644
+--- a/include/orcus/sax_parser.hpp
++++ b/include/orcus/sax_parser.hpp
+@@ -171,6 +171,8 @@ void sax_parser<_Handler,_Config>::element_open(std::ptrdiff_t begin_pos)
+             m_handler.start_element(elem);
+             reset_buffer_pos();
+             m_handler.end_element(elem);
++            if (!m_nest_level)
++                m_root_elem_open = false;
+ #if ORCUS_DEBUG_SAX_PARSER
+             cout << "element_open: ns='" << elem.ns << "', name='" << elem.name << "' (self-closing)" << endl;
+ #endif
+-- 
+2.7.4
+
diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk
index 08f3423f2424..51f6e55e1de1 100644
--- a/external/liborcus/UnpackedTarball_liborcus.mk
+++ b/external/liborcus/UnpackedTarball_liborcus.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,liborcus,1))
 $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
 	external/liborcus/0001-workaround-a-linking-problem-on-windows.patch \
 	external/liborcus/rpath.patch.0 \
+	external/liborcus/0001-protect-the-self-closing-xml-element-code-against-se.patch \
 ))
 
 ifeq ($(OS),WNT)
commit d4679841c0cade5babb9b1c1a5938f2b6e3bfb91
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 24 22:24:03 2018 +0100

    curl: fix CVE-2018-1000005/1000007
    
    * don't upgrade to new release, no idea how the new windows
      build system likes targeting Win XP which is still supported in 5.4
    
    Change-Id: I4fbd7f1c5f1f0563895f6f8ede10063621d10a4b
    Reviewed-on: https://gerrit.libreoffice.org/48542
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit ed497921314ebd41fce3483c92ca433b502628ca)

diff --git a/external/curl/CVE-2018-1000005.patch b/external/curl/CVE-2018-1000005.patch
new file mode 100644
index 000000000000..7b5578b1aacc
--- /dev/null
+++ b/external/curl/CVE-2018-1000005.patch
@@ -0,0 +1,36 @@
+From fa3dbb9a147488a2943bda809c66fc497efe06cb Mon Sep 17 00:00:00 2001
+From: Zhouyihai Ding <ddyihai at ddyihai.svl.corp.google.com>
+Date: Wed, 10 Jan 2018 10:12:18 -0800
+Subject: [PATCH] http2: fix incorrect trailer buffer size
+
+Prior to this change the stored byte count of each trailer was
+miscalculated and 1 less than required. It appears any trailer
+after the first that was passed to Curl_client_write would be truncated
+or corrupted as well as the size. Potentially the size of some
+subsequent trailer could be erroneously extracted from the contents of
+that trailer, and since that size is used by client write an
+out-of-bounds read could occur and cause a crash or be otherwise
+processed by client write.
+
+The bug appears to have been born in 0761a51 (precedes 7.49.0).
+
+Closes https://github.com/curl/curl/pull/2231
+---
+ lib/http2.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/http2.c b/lib/http2.c
+index 8e2fc71996..699287940e 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -925,8 +925,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
+ 
+   if(stream->bodystarted) {
+     /* This is trailer fields. */
+-    /* 3 is for ":" and "\r\n". */
+-    uint32_t n = (uint32_t)(namelen + valuelen + 3);
++    /* 4 is for ": " and "\r\n". */
++    uint32_t n = (uint32_t)(namelen + valuelen + 4);
+ 
+     DEBUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
+                  value));
diff --git a/external/curl/CVE-2018-1000007.patch b/external/curl/CVE-2018-1000007.patch
new file mode 100644
index 000000000000..c474370c78ad
--- /dev/null
+++ b/external/curl/CVE-2018-1000007.patch
@@ -0,0 +1,110 @@
+From af32cd3859336ab963591ca0df9b1e33a7ee066b Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel at haxx.se>
+Date: Fri, 19 Jan 2018 13:19:25 +0100
+Subject: [PATCH] http: prevent custom Authorization headers in redirects
+
+... unless CURLOPT_UNRESTRICTED_AUTH is set to allow them. This matches how
+curl already handles Authorization headers created internally.
+
+Note: this changes behavior slightly, for the sake of reducing mistakes.
+
+Added test 317 and 318 to verify.
+
+Reported-by: Craig de Stigter
+Bug: https://curl.haxx.se/docs/adv_2018-b3bf.html
+---
+ docs/libcurl/opts/CURLOPT_HTTPHEADER.3 | 12 ++++-
+ lib/http.c                             | 10 +++-
+ lib/setopt.c                           |  2 +-
+ lib/urldata.h                          |  2 +-
+ tests/data/Makefile.inc                |  2 +-
+ tests/data/test317                     | 94 +++++++++++++++++++++++++++++++++
+ tests/data/test318                     | 95 ++++++++++++++++++++++++++++++++++
+ 7 files changed, 212 insertions(+), 5 deletions(-)
+ create mode 100644 tests/data/test317
+ create mode 100644 tests/data/test318
+
+diff --git a/docs/libcurl/opts/CURLOPT_HTTPHEADER.3 b/docs/libcurl/opts/CURLOPT_HTTPHEADER.3
+index c5ccb1a53d..c9f29e393e 100644
+--- a/docs/libcurl/opts/CURLOPT_HTTPHEADER.3
++++ b/docs/libcurl/opts/CURLOPT_HTTPHEADER.3
+@@ -5,7 +5,7 @@
+ .\" *                            | (__| |_| |  _ <| |___
+ .\" *                             \___|\___/|_| \_\_____|
+ .\" *
+-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel at haxx.se>, et al.
++.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel at haxx.se>, et al.
+ .\" *
+ .\" * This software is licensed as described in the file COPYING, which
+ .\" * you should have received as part of this distribution. The terms
+@@ -77,6 +77,16 @@ the headers. They may be private or otherwise sensitive to leak.
+ 
+ Use \fICURLOPT_HEADEROPT(3)\fP to make the headers only get sent to where you
+ intend them to get sent.
++
++Custom headers are sent in all requests done by the easy handles, which
++implies that if you tell libcurl to follow redirects
++(\fBCURLOPT_FOLLOWLOCATION(3)\fP), the same set of custom headers will be sent
++in the subsequent request. Redirects can of course go to other hosts and thus
++those servers will get all the contents of your custom headers too.
++
++Starting in 7.58.0, libcurl will specifically prevent "Authorization:" headers
++from being sent to other hosts than the first used one, unless specifically
++permitted with the \fBCURLOPT_UNRESTRICTED_AUTH(3)\fP option.
+ .SH DEFAULT
+ NULL
+ .SH PROTOCOLS
+diff --git a/lib/http.c b/lib/http.c
+index c1cdf2da02..a5007670d7 100644
+--- a/lib/http.c
++++ b/lib/http.c
+@@ -714,7 +714,7 @@ Curl_http_output_auth(struct connectdata *conn,
+   if(!data->state.this_is_a_follow ||
+      conn->bits.netrc ||
+      !data->state.first_host ||
+-     data->set.http_disable_hostname_check_before_authentication ||
++     data->set.allow_auth_to_other_hosts ||
+      strcasecompare(data->state.first_host, conn->host.name)) {
+     result = output_auth_headers(conn, authhost, request, path, FALSE);
+   }
+@@ -1636,6 +1636,14 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
+                   checkprefix("Transfer-Encoding:", headers->data))
+             /* HTTP/2 doesn't support chunked requests */
+             ;
++          else if(checkprefix("Authorization:", headers->data) &&
++                  /* be careful of sending this potentially sensitive header to
++                     other hosts */
++                  (data->state.this_is_a_follow &&
++                   data->state.first_host &&
++                   !data->set.allow_auth_to_other_hosts &&
++                   !strcasecompare(data->state.first_host, conn->host.name)))
++            ;
+           else {
+             CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n",
+                                                headers->data);
+diff --git a/lib/setopt.c b/lib/setopt.c
+index 66f30ea653..a5ef75c722 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -976,7 +976,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
+      * Send authentication (user+password) when following locations, even when
+      * hostname changed.
+      */
+-    data->set.http_disable_hostname_check_before_authentication =
++    data->set.allow_auth_to_other_hosts =
+       (0 != va_arg(param, long)) ? TRUE : FALSE;
+     break;
+ 
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 4dcd1a322c..5c04ad1720 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -1599,7 +1599,7 @@ struct UserDefined {
+   bool http_keep_sending_on_error; /* for HTTP status codes >= 300 */
+   bool http_follow_location; /* follow HTTP redirects */
+   bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */
+-  bool http_disable_hostname_check_before_authentication;
++  bool allow_auth_to_other_hosts;
+   bool include_header;   /* include received protocol headers in data output */
+   bool http_set_referer; /* is a custom referer used */
+   bool http_auto_referer; /* set "correct" referer when following location: */
diff --git a/external/curl/UnpackedTarball_curl.mk b/external/curl/UnpackedTarball_curl.mk
index 4cabf2f1b80b..f9f3a8bf6016 100644
--- a/external/curl/UnpackedTarball_curl.mk
+++ b/external/curl/UnpackedTarball_curl.mk
@@ -24,6 +24,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,curl,\
 	external/curl/curl-7.26.0_win-proxy.patch \
 	external/curl/curl-xp.patch.1 \
 	external/curl/CVE-2017-8816.patch \
+	external/curl/CVE-2018-1000005.patch \
+	external/curl/CVE-2018-1000007.patch \
 ))
 
 ifeq ($(SYSTEM_NSS),)
commit 2fee2505a74685360aa6707fef30e689955230ba
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 29 12:28:03 2017 +0100

    curl: fix CVE-2017-8816
    
    * don't upgrade to new release, no idea how the new windows
      build system likes targeting Win XP which is still supported in 5.4
    * CVE-2017-8817 doesn't affect LO as CURLOPT_WILDCARDMATCH isn't used
    * CVE-2017-8818 doesn't affect the old 7.52 version
    
    Change-Id: I49ddb771ccdb93d5fe8f4b3544f74ab9b171c156
    Reviewed-on: https://gerrit.libreoffice.org/45487
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit aa0f44de5b260b2b2a39bdd2de9445d72ab14265)

diff --git a/external/curl/CVE-2017-8816.patch b/external/curl/CVE-2017-8816.patch
new file mode 100644
index 000000000000..dd4fa677e03f
--- /dev/null
+++ b/external/curl/CVE-2017-8816.patch
@@ -0,0 +1,67 @@
+From 7947c50bcd09cf471c95511739bc66d2cb506ee2 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel at haxx.se>
+Date: Mon, 6 Nov 2017 23:51:52 +0100
+Subject: [PATCH] ntlm: avoid integer overflow for malloc size
+
+Reported-by: Alex Nichols
+Assisted-by: Kamil Dudka and Max Dymond
+
+CVE-2017-8816
+
+Bug: https://curl.haxx.se/docs/adv_2017-11e7.html
+---
+ lib/curl_ntlm_core.c | 23 +++++++++++++++++++++--
+ 1 file changed, 21 insertions(+), 2 deletions(-)
+
+diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
+index 1309bf0d9..e8962769c 100644
+--- a/lib/curl_ntlm_core.c
++++ b/lib/curl_ntlm_core.c
+@@ -644,23 +644,42 @@ CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
+   Curl_HMAC_final(ctxt, output);
+ 
+   return CURLE_OK;
+ }
+ 
++#ifndef SIZE_T_MAX
++/* some limits.h headers have this defined, some don't */
++#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
++#define SIZE_T_MAX 18446744073709551615U
++#else
++#define SIZE_T_MAX 4294967295U
++#endif
++#endif
++
+ /* This creates the NTLMv2 hash by using NTLM hash as the key and Unicode
+  * (uppercase UserName + Domain) as the data
+  */
+ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
+                                        const char *domain, size_t domlen,
+                                        unsigned char *ntlmhash,
+                                        unsigned char *ntlmv2hash)
+ {
+   /* Unicode representation */
+-  size_t identity_len = (userlen + domlen) * 2;
+-  unsigned char *identity = malloc(identity_len);
++  size_t identity_len;
++  unsigned char *identity;
+   CURLcode result = CURLE_OK;
+ 
++  /* we do the length checks below separately to avoid integer overflow risk
++     on extreme data lengths */
++  if((userlen > SIZE_T_MAX/2) ||
++     (domlen > SIZE_T_MAX/2) ||
++     ((userlen + domlen) > SIZE_T_MAX/2))
++    return CURLE_OUT_OF_MEMORY;
++
++  identity_len = (userlen + domlen) * 2;
++  identity = malloc(identity_len);
++
+   if(!identity)
+     return CURLE_OUT_OF_MEMORY;
+ 
+   ascii_uppercase_to_unicode_le(identity, user, userlen);
+   ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);
+-- 
+2.15.0
+
diff --git a/external/curl/UnpackedTarball_curl.mk b/external/curl/UnpackedTarball_curl.mk
index 6a5720d78459..4cabf2f1b80b 100644
--- a/external/curl/UnpackedTarball_curl.mk
+++ b/external/curl/UnpackedTarball_curl.mk
@@ -23,6 +23,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,curl,\
 	external/curl/curl-7.26.0_mingw.patch \
 	external/curl/curl-7.26.0_win-proxy.patch \
 	external/curl/curl-xp.patch.1 \
+	external/curl/CVE-2017-8816.patch \
 ))
 
 ifeq ($(SYSTEM_NSS),)


More information about the Libreoffice-commits mailing list