diff options
142 files changed, 2597 insertions, 1160 deletions
diff --git a/Makefile.in b/Makefile.in index 393e94fda331..9fd266106cb3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,7 +60,7 @@ else # MAKE_RESTARTS all: build check-if-root: - @if test ! `uname` = 'Haiku' -a `id -u` = 0 && ! grep -q 'lxc\|docker' /proc/self/cgroup; then \ + @if test ! `uname` = 'Haiku' -a `id -u` = 0 && test -z $$container && ! grep -q 'lxc\|docker' /proc/self/cgroup && ! grep -q 'libpod_parent' /proc/self/cgroup; then \ echo; \ echo 'Building LibreOffice as root is a very bad idea, use a regular user.'; \ echo; \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index ad97513d677e..da4aad2d956f 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -2753,7 +2753,7 @@ $(call gb_LinkTarget_set_include,$(1),\ ifeq ($(COM),MSC) $(call gb_LinkTarget_add_libs,$(1),\ - $(call gb_UnpackedTarball_get_dir,curl)/builds/libcurl-vc12-$(if $(filter X86_64,$(CPUNAME)),x64,x86)-$(if $(MSVC_USE_DEBUG_RUNTIME),debug,release)-dll-ipv6-sspi-winssl/lib/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).lib \ + $(call gb_UnpackedTarball_get_dir,curl)/builds/libcurl-vc12-$(if $(filter X86_64,$(CPUNAME)),x64,x86)-$(if $(MSVC_USE_DEBUG_RUNTIME),debug,release)-dll-ipv6-sspi-schannel/lib/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).lib \ ) else $(call gb_LinkTarget_add_libs,$(1),\ @@ -3432,6 +3432,11 @@ $(call gb_LinkTarget_add_libs,$(1),\ endef +define gb_LinkTarget__use_nssutil3 +$(call gb_LinkTarget__use_nss3,$(1)) + +endef + define gb_LinkTarget__use_plc4 $(call gb_LinkTarget__use_nss3,$(1)) @@ -3501,6 +3506,27 @@ endif endef +define gb_LinkTarget__use_nssutil3 +$(call gb_LinkTarget_use_package,$(1),nss) +$(call gb_LinkTarget_set_include,$(1),\ + $$(INCLUDE) \ + -I$(call gb_UnpackedTarball_get_dir,nss)/dist/public/nss \ + -I$(call gb_UnpackedTarball_get_dir,nss)/dist/out/include \ +) + +ifeq ($(COM),MSC) +$(call gb_LinkTarget_add_libs,$(1),\ + $(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib/nssutil3.lib \ +) +else +$(call gb_LinkTarget_add_libs,$(1),\ + -L$(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib \ + -lnssutil3 \ +) +endif + +endef + define gb_ExternalProject__use_nss3 $(call gb_ExternalProject_use_package,$(1),nss) diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index 090ec5c13e38..b4d231436440 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -240,7 +240,7 @@ void #include <malloc.h> #include <new.h> -#include <typeinfo.h> +#include <typeinfo> #include <signal.h> #include <rtl/alloc.h> diff --git a/config_host.mk.in b/config_host.mk.in index 9ed3802ad761..6bf5258e948e 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -217,7 +217,6 @@ export GNUTLS_CFLAGS=$(gb_SPACE)@GNUTLS_CFLAGS@ export GNUTLS_LIBS=$(gb_SPACE)@GNUTLS_LIBS@ export PARALLELISM?=@PARALLELISM@ @x_GNUCP@ export GNUCOPY=@GNUCP@ -export GNUMAKE_WIN_NATIVE=@GNUMAKE_WIN_NATIVE@ export GNUPATCH=@GNUPATCH@ export GNUTAR=@GNUTAR@ export GOBJECT_CFLAGS=$(gb_SPACE)@GOBJECT_CFLAGS@ diff --git a/configure.ac b/configure.ac index 5c7331e13f08..814a9bad75ca 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ dnl in order to create a configure script. # several non-alphanumeric characters, those are split off and used only for the # ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea. -AC_INIT([LibreOffice],[6.2.9.11],[],[],[http://documentfoundation.org/]) +AC_INIT([LibreOffice],[6.2.9.12],[],[],[http://documentfoundation.org/]) AC_PREREQ([2.59]) @@ -4973,7 +4973,6 @@ else fi rm -rf $TESTGMAKEFILEFUNC AC_SUBST(HAVE_GNUMAKE_FILE_FUNC) -AC_SUBST(GNUMAKE_WIN_NATIVE) _make_ver_check=`$GNUMAKE --version | grep "Built for Windows"` STALE_MAKE= diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index a93f3401cabc..0d2853e73105 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -74,9 +74,15 @@ inline connectivity::OSQLInternalNode* newNode(const OUString& _newValue, // yyi is the internal number of the rule that is currently being reduced // This can be mapped to external rule number via the yyrmap. +#if defined YYBISON && YYBISON >= 30800 +#define SQL_NEW_RULE newNode("", SQLNodeType::Rule, yyr1[yyrule]) +#define SQL_NEW_LISTRULE newNode("", SQLNodeType::ListRule, yyr1[yyrule]) +#define SQL_NEW_COMMALISTRULE newNode("", SQLNodeType::CommaListRule, yyr1[yyrule]) +#else #define SQL_NEW_RULE newNode("", SQLNodeType::Rule, yyr1[yyn]) #define SQL_NEW_LISTRULE newNode("", SQLNodeType::ListRule, yyr1[yyn]) #define SQL_NEW_COMMALISTRULE newNode("", SQLNodeType::CommaListRule, yyr1[yyn]) +#endif extern connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER; diff --git a/cppu/qa/cppumaker/test_cppumaker.cxx b/cppu/qa/cppumaker/test_cppumaker.cxx index 0ac7f854fe76..e73a502333f8 100644 --- a/cppu/qa/cppumaker/test_cppumaker.cxx +++ b/cppu/qa/cppumaker/test_cppumaker.cxx @@ -360,7 +360,6 @@ #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/plugin/TestPlugIn.h> -#include <o3tl/cppunittraitshelper.hxx> #include <rtl/ustring.hxx> #include <cstddef> diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx index ea4013b2e2bc..7787176ffd3b 100644 --- a/cppu/qa/test_any.cxx +++ b/cppu/qa/test_any.cxx @@ -50,7 +50,6 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Type.hxx> #include <com/sun/star/uno/XInterface.hpp> -#include <o3tl/cppunittraitshelper.hxx> #include <osl/interlck.h> #include <rtl/string.h> #include <rtl/ustring.h> diff --git a/download.lst b/download.lst index 248efc6701a5..b173daa9dcb5 100644 --- a/download.lst +++ b/download.lst @@ -29,8 +29,8 @@ export CPPUNIT_SHA256SUM := 3d569869d27b48860210c758c4f313082103a5e58219a7669b52 export CPPUNIT_TARBALL := cppunit-1.14.0.tar.gz export CT2N_SHA256SUM := 71b238efd2734be9800af07566daea8d6685aeed28db5eb5fa0e6453f4d85de3 export CT2N_TARBALL := 1f467e5bb703f12cbbb09d5cf67ecf4a-converttexttonumber-1-5-0.oxt -export CURL_SHA256SUM := cdf18794393d8bead915312708a9e5d819c6e9919de14b20d5c8e7987abd9772 -export CURL_TARBALL := curl-7.71.0.tar.xz +export CURL_SHA256SUM := 2cb9c2356e7263a1272fd1435ef7cdebf2cd21400ec287b068396deb705c22c4 +export CURL_TARBALL := curl-7.83.1.tar.xz export EBOOK_SHA256SUM := 7e8d8ff34f27831aca3bc6f9cc532c2f90d2057c778963b884ff3d1e34dfe1f9 export EBOOK_TARBALL := libe-book-0.1.3.tar.xz export EPOXY_SHA256SUM := 002958c5528321edd53440235d3c44e71b5b1e09b9177e8daf677450b6c4433d @@ -42,8 +42,8 @@ export EPUBGEN_TARBALL := libepubgen-0.1.1.tar.xz export ETONYEK_SHA256SUM := e61677e8799ce6e55b25afc11aa5339113f6a49cff031f336e32fa58635b1a4a export ETONYEK_VERSION_MICRO := 9 export ETONYEK_TARBALL := libetonyek-0.1.$(ETONYEK_VERSION_MICRO).tar.xz -export EXPAT_SHA256SUM := 9a130948b05a82da34e4171d5f5ae5d321d9630277af02c8fa51e431f6475102 -export EXPAT_TARBALL := expat-2.2.8.tar.bz2 +export EXPAT_SHA256SUM := de55794b7a9bc214852fdc075beaaecd854efe1361597e6268ee87946951289b +export EXPAT_TARBALL := expat-2.4.6.tar.xz export FIREBIRD_SHA256SUM := 6994be3555e23226630c587444be19d309b25b0fcf1f87df3b4e3f88943e5860 export FIREBIRD_TARBALL := Firebird-3.0.0.32483-0.tar.bz2 export FONTCONFIG_SHA256SUM := cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017 @@ -94,8 +94,8 @@ export GLM_SHA256SUM := d0312c360efe04dd048b3311fe375ff36f1993b4c2e3cb58c8106299 export GLM_TARBALL := bae83fa5dc7f081768daace6e199adc3-glm-0.9.4.6-libreoffice.zip export GPGME_SHA256SUM := 1b29fedb8bfad775e70eafac5b0590621683b2d9869db994568e6401f4034ceb export GPGME_TARBALL := gpgme-1.9.0.tar.bz2 -export GRAPHITE_SHA256SUM := aa5e58356cd084000609ebbd93fef456a1bc0ab9e46fea20e81552fb286232a9 -export GRAPHITE_TARBALL := graphite2-minimal-1.3.10.tgz +export GRAPHITE_SHA256SUM := 0ebf80886bfc39e591c59bc975f4bb5dc717da7489eedfdb8acf84435261e7df +export GRAPHITE_TARBALL := graphite2-minimal-1.3.12.tgz export HARFBUZZ_SHA256SUM := 3c592f86fa0da69e2e0e98cae9f5d5b61def3bb7948aa00ca45748f27fa545fd export HARFBUZZ_TARBALL := harfbuzz-1.8.4.tar.bz2 export HSQLDB_SHA256SUM := d30b13f4ba2e3b6a2d4f020c0dee0a9fb9fc6fbcc2d561f36b78da4bf3802370 @@ -156,12 +156,12 @@ export LIBTOMMATH_SHA256SUM := 083daa92d8ee6f4af96a6143b12d7fc8fe1a547e14f862304 export LIBTOMMATH_TARBALL := ltm-1.0.zip export XMLSEC_SHA256SUM := 97d756bad8e92588e6997d2227797eaa900d05e34a426829b149f65d87118eb6 export XMLSEC_TARBALL := xmlsec1-1.2.27.tar.gz -export LIBXML_SHA256SUM := aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f -export LIBXML_VERSION_MICRO := 10 -export LIBXML_TARBALL := libxml2-2.9.$(LIBXML_VERSION_MICRO).tar.gz -export LIBXSLT_SHA256SUM := 98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f -export LIBXSLT_VERSION_MICRO := 34 -export LIBXSLT_TARBALL := libxslt-1.1.$(LIBXSLT_VERSION_MICRO).tar.gz +export LIBXML_SHA256SUM := 60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee +export LIBXML_VERSION_MICRO := 14 +export LIBXML_TARBALL := libxml2-2.9.$(LIBXML_VERSION_MICRO).tar.xz +export LIBXSLT_SHA256SUM := 8247f33e9a872c6ac859aa45018bc4c4d00b97e2feac9eebc10c93ce1f34dd79 +export LIBXSLT_VERSION_MICRO := 35 +export LIBXSLT_TARBALL := libxslt-1.1.$(LIBXSLT_VERSION_MICRO).tar.xz export LPSOLVE_SHA256SUM := 171816288f14215c69e730f7a4f1c325739873e21f946ff83884b350574e6695 export LPSOLVE_TARBALL := 26b3e95ddf3d9c077c480ea45874b3b8-lp_solve_5.5.tar.gz export LXML_SHA256SUM := 940caef1ec7c78e0c34b0f6b94fe42d0f2022915ffc78643d28538a5cfd0f40e @@ -181,8 +181,8 @@ export MYTHES_SHA256SUM := 1e81f395d8c851c3e4e75b568e20fa2fa549354e75ab397f9de4b export MYTHES_TARBALL := a8c2c5b8f09e7ede322d5c602ff6a4b6-mythes-1.2.4.tar.gz export NEON_SHA256SUM := db0bd8cdec329b48f53a6f00199c92d5ba40b0f015b153718d1b15d3d967fbca export NEON_TARBALL := neon-0.30.2.tar.gz -export NSS_SHA256SUM := ec6032d78663c6ef90b4b83eb552dedf721d2bce208cec3bf527b8f637db7e45 -export NSS_TARBALL := nss-3.55-with-nspr-4.27.tar.gz +export NSS_SHA256SUM := 07a9e5b70f121a62706140d4cacc3006d3efb869da40f3a2bf7a65d37847f4d9 +export NSS_TARBALL := nss-3.73-with-nspr-4.32.tar.gz export ODFGEN_SHA256SUM := 2c7b21892f84a4c67546f84611eccdad6259875c971e98ddb027da66ea0ac9c2 export ODFGEN_VERSION_MICRO := 6 export ODFGEN_TARBALL := libodfgen-0.1.$(ODFGEN_VERSION_MICRO).tar.bz2 @@ -190,8 +190,8 @@ export ODFVALIDATOR_SHA256SUM := 984f2a479df79e27e7b01a5815ac53ae64e07746b882262 export ODFVALIDATOR_JAR := odfvalidator-1.2.0-incubating-SNAPSHOT-jar-with-dependencies-971c54fd38a968f5860014b44301872706f9e540.jar export OFFICEOTRON_SHA256SUM := f2443f27561af52324eee03a1892d9f569adc8db9e7bca55614898bc2a13a770 export OFFICEOTRON_JAR := 8249374c274932a21846fa7629c2aa9b-officeotron-0.7.4-master.jar -export OPENLDAP_SHA256SUM := cdd6cffdebcd95161a73305ec13fc7a78e9707b46ca9f84fb897cd5626df3824 -export OPENLDAP_TARBALL := openldap-2.4.45.tgz +export OPENLDAP_SHA256SUM := 99f37d6747d88206c470067eda624d5e48c1011e943ec0ab217bae8712e22f34 +export OPENLDAP_TARBALL := openldap-2.4.59.tgz export OPENSSL_SHA256SUM := ae51d08bba8a83958e894946f15303ff894d75c2b8bbd44a852b64e3fe11d0d6 export OPENSSL_TARBALL := openssl-1.0.2r.tar.gz export ORCUS_SHA256SUM := 3f48cfbc21ad74787218284939c04d42cb836c73bc393f27f538b668e4d78a5f @@ -200,16 +200,16 @@ export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b633 export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d export PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz -export PDFIUM_SHA256SUM := eca406d47ac7e2a84dcc86f93c08f96e591d409589e881477fa75e488e4851d8 -export PDFIUM_TARBALL := pdfium-4306.tar.bz2 +export PDFIUM_SHA256SUM := eb98a77eaaab9e9e8de541cfd18b9438dd3c538bd5ef163820353179727f5dc9 +export PDFIUM_TARBALL := pdfium-4643.tar.bz2 export PIXMAN_SHA256SUM := 21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e export PIXMAN_TARBALL := e80ebae4da01e77f68744319f01d52a3-pixman-0.34.0.tar.gz export LIBPNG_SHA256SUM := 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca export LIBPNG_TARBALL := libpng-1.6.37.tar.xz export POPPLER_SHA256SUM := 016dde34e5f868ea98a32ca99b643325a9682281500942b7113f4ec88d20e2f3 export POPPLER_TARBALL := poppler-21.01.0.tar.xz -export POSTGRESQL_SHA256SUM := 12345c83b89aa29808568977f5200d6da00f88a035517f925293355432ffe61f -export POSTGRESQL_TARBALL := postgresql-13.1.tar.bz2 +export POSTGRESQL_SHA256SUM := 9b81067a55edbaabc418aacef457dd8477642827499560b00615a6ea6c13f6b3 +export POSTGRESQL_TARBALL := postgresql-13.5.tar.bz2 export PYTHON_SHA256SUM := c24a37c63a67f53bdd09c5f287b5cff8e8b98f857bf348c577d454d3f74db049 export PYTHON_TARBALL := Python-3.5.9.tar.xz export QXP_SHA256SUM := e137b6b110120a52c98edd02ebdc4095ee08d0d5295a94316a981750095a945c @@ -249,8 +249,8 @@ export WPS_VERSION_MICRO := 10 export WPS_TARBALL := libwps-0.4.$(WPS_VERSION_MICRO).tar.xz export XSLTML_SHA256SUM := 75823776fb51a9c526af904f1503a7afaaab900fba83eda64f8a41073724c870 export XSLTML_TARBALL := a7983f859eafb2677d7ff386a023bc40-xsltml_2.1.2.zip -export ZLIB_SHA256SUM := 4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 -export ZLIB_TARBALL := zlib-1.2.11.tar.xz +export ZLIB_SHA256SUM := 7db46b8d7726232a621befaab4a1c870f00a90805511c0e0090441dac57def18 +export ZLIB_TARBALL := zlib-1.2.12.tar.xz export ZMF_SHA256SUM := 27051a30cb057fdb5d5de65a1f165c7153dc76e27fe62251cbb86639eb2caf22 export ZMF_TARBALL := libzmf-0.0.2.tar.xz diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 6e4859f0bad7..0a26aff9ef54 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -350,7 +350,7 @@ namespace emfplushelper } else // we use a pen { - const EMFPPen* pen = static_cast<EMFPPen*>(maEMFPObjects[brushIndexOrColor & 0xff].get()); + const EMFPPen* pen = dynamic_cast<EMFPPen*>(maEMFPObjects[brushIndexOrColor & 0xff].get()); if (pen) { color = pen->GetColor(); @@ -535,7 +535,7 @@ namespace emfplushelper } else // use Brush { - EMFPBrush* brush = static_cast<EMFPBrush*>( maEMFPObjects[brushIndexOrColor & 0xff].get() ); + EMFPBrush* brush = dynamic_cast<EMFPBrush*>( maEMFPObjects[brushIndexOrColor & 0xff].get() ); SAL_INFO("drawinglayer", "EMF+\t Fill polygon, brush slot: " << brushIndexOrColor << " (brush type: " << (brush ? brush->GetType() : -1) << ")"); // give up in case something wrong happened @@ -1033,7 +1033,11 @@ namespace emfplushelper rMS.ReadUInt32(brushIndexOrColor); SAL_INFO("drawinglayer", "EMF+ FillRegion slot: " << index); - EMFPPlusFillPolygon(static_cast<EMFPRegion*>(maEMFPObjects[flags & 0xff].get())->regionPolyPolygon, flags & 0x8000, brushIndexOrColor); + EMFPRegion* region = dynamic_cast<EMFPRegion*>(maEMFPObjects[flags & 0xff].get()); + if (region) + EMFPPlusFillPolygon(region->regionPolyPolygon, flags & 0x8000, brushIndexOrColor); + else + SAL_WARN("drawinglayer.emf", "EMF+\tEmfPlusRecordTypeFillRegion missing region"); } break; case EmfPlusRecordTypeDrawEllipse: @@ -1210,9 +1214,10 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\tTODO: use image attributes"); // For DrawImage and DrawImagePoints, source unit of measurement type must be 1 pixel - if (sourceUnit == UnitTypePixel && maEMFPObjects[flags & 0xff].get()) + if (EMFPImage* image = sourceUnit == UnitTypePixel ? + dynamic_cast<EMFPImage*>(maEMFPObjects[flags & 0xff].get()) : + nullptr) { - EMFPImage& image = *static_cast<EMFPImage *>(maEMFPObjects[flags & 0xff].get()); float sx, sy, sw, sh; ReadRectangle(rMS, sx, sy, sw, sh); ::tools::Rectangle aSource(Point(sx, sy), Size(sw, sh)); @@ -1262,9 +1267,9 @@ namespace emfplushelper aDstPoint.getX(), aDstPoint.getY()); - if (image.type == ImageDataTypeBitmap) + if (image->type == ImageDataTypeBitmap) { - BitmapEx aBmp(image.graphic.GetBitmapEx()); + BitmapEx aBmp(image->graphic.GetBitmapEx()); aBmp.Crop(aSource); Size aSize(aBmp.GetSizePixel()); SAL_INFO("drawinglayer", "EMF+\t bitmap size: " << aSize.Width() << "x" << aSize.Height()); @@ -1278,9 +1283,9 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\t warning: empty bitmap"); } } - else if (image.type == ImageDataTypeMetafile) + else if (image->type == ImageDataTypeMetafile) { - GDIMetaFile aGDI(image.graphic.GetGDIMetaFile()); + GDIMetaFile aGDI(image->graphic.GetGDIMetaFile()); aGDI.Clip(aSource); mrTargetHolders.Current().append( o3tl::make_unique<drawinglayer::primitive2d::MetafilePrimitive2D>(aTransformMatrix, aGDI)); @@ -1314,7 +1319,7 @@ namespace emfplushelper // get the stringFormat from the Object table ( this is OPTIONAL and may be nullptr ) const EMFPStringFormat *stringFormat = dynamic_cast<EMFPStringFormat*>(maEMFPObjects[formatId & 0xff].get()); // get the font from the flags - const EMFPFont *font = static_cast< EMFPFont* >( maEMFPObjects[flags & 0xff].get() ); + const EMFPFont *font = dynamic_cast<EMFPFont*>(maEMFPObjects[flags & 0xff].get()); if (!font) { break; @@ -1680,7 +1685,7 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+ SetClipPath combine mode: " << combineMode); SAL_INFO("drawinglayer", "EMF+\tpath in slot: " << (flags & 0xff)); - EMFPPath *path = static_cast<EMFPPath*>(maEMFPObjects[flags & 0xff].get()); + EMFPPath *path = dynamic_cast<EMFPPath*>(maEMFPObjects[flags & 0xff].get()); if (!path) { break; @@ -1697,7 +1702,7 @@ namespace emfplushelper int combineMode = (flags >> 8) & 0xf; SAL_INFO("drawinglayer", "EMF+ SetClipRegion"); SAL_INFO("drawinglayer", "EMF+\tregion in slot: " << (flags & 0xff) << " combine mode: " << combineMode); - EMFPRegion *region = static_cast<EMFPRegion*>(maEMFPObjects[flags & 0xff].get()); + EMFPRegion *region = dynamic_cast<EMFPRegion*>(maEMFPObjects[flags & 0xff].get()); if (!region) { break; @@ -1765,7 +1770,7 @@ namespace emfplushelper } // get the font from the flags - EMFPFont *font = static_cast< EMFPFont* >( maEMFPObjects[flags & 0xff].get() ); + EMFPFont *font = dynamic_cast<EMFPFont*>(maEMFPObjects[flags & 0xff].get()); if (!font) { break; diff --git a/external/coinmp/UnpackedTarball_coinmp.mk b/external/coinmp/UnpackedTarball_coinmp.mk index 35cfbfcdbae8..a918effb1203 100644 --- a/external/coinmp/UnpackedTarball_coinmp.mk +++ b/external/coinmp/UnpackedTarball_coinmp.mk @@ -40,6 +40,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,coinmp,\ external/coinmp/ubsan.patch.0 \ external/coinmp/rpath.patch \ external/coinmp/libtool.patch \ + external/coinmp/register.patch \ + external/coinmp/configure-exit.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/coinmp/configure-exit.patch b/external/coinmp/configure-exit.patch new file mode 100644 index 000000000000..0a81b8073fd2 --- /dev/null +++ b/external/coinmp/configure-exit.patch @@ -0,0 +1,33 @@ +--- Cgl/configure ++++ Cgl/configure +@@ -3501,8 +3501,6 @@ + fi + for ac_declaration in \ + '' \ +- 'extern "C" void std::exit (int) throw (); using std::exit;' \ +- 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +--- Clp/configure ++++ Clp/configure +@@ -3528,8 +3528,6 @@ + fi + for ac_declaration in \ + '' \ +- 'extern "C" void std::exit (int) throw (); using std::exit;' \ +- 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +--- CoinUtils/configure ++++ CoinUtils/configure +@@ -3527,8 +3527,6 @@ + fi + for ac_declaration in \ + '' \ +- 'extern "C" void std::exit (int) throw (); using std::exit;' \ +- 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' diff --git a/external/coinmp/register.patch b/external/coinmp/register.patch new file mode 100644 index 000000000000..cf4ca4d06c01 --- /dev/null +++ b/external/coinmp/register.patch @@ -0,0 +1,369 @@ +--- CoinUtils/src/CoinHelperFunctions.hpp ++++ CoinUtils/src/CoinHelperFunctions.hpp +@@ -41,7 +41,7 @@ + handled correctly. */ + + template <class T> inline void +-CoinCopyN(register const T* from, const int size, register T* to) ++CoinCopyN(const T* from, const int size, T* to) + { + if (size == 0 || from == to) + return; +@@ -52,10 +52,10 @@ + "CoinCopyN", ""); + #endif + +- register int n = (size + 7) / 8; ++ int n = (size + 7) / 8; + if (to > from) { +- register const T* downfrom = from + size; +- register T* downto = to + size; ++ const T* downfrom = from + size; ++ T* downto = to + size; + // Use Duff's device to copy + switch (size % 8) { + case 0: do{ *--downto = *--downfrom; +@@ -99,7 +99,7 @@ + the difference down to int. -- lh, 100823 -- + */ + template <class T> inline void +-CoinCopy(register const T* first, register const T* last, register T* to) ++CoinCopy(const T* first, const T* last, T* to) + { + CoinCopyN(first, static_cast<int>(last-first), to); + } +@@ -114,7 +114,7 @@ + Note JJF - the speed claim seems to be false on IA32 so I have added + CoinMemcpyN which can be used for atomic data */ + template <class T> inline void +-CoinDisjointCopyN(register const T* from, const int size, register T* to) ++CoinDisjointCopyN(const T* from, const int size, T* to) + { + #ifndef _MSC_VER + if (size == 0 || from == to) +@@ -135,7 +135,7 @@ + throw CoinError("overlapping arrays", "CoinDisjointCopyN", ""); + #endif + +- for (register int n = size / 8; n > 0; --n, from += 8, to += 8) { ++ for (int n = size / 8; n > 0; --n, from += 8, to += 8) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; +@@ -167,8 +167,8 @@ + are copied at a time. The source array is given by its first and "after + last" entry; the target array is given by its first entry. */ + template <class T> inline void +-CoinDisjointCopy(register const T* first, register const T* last, +- register T* to) ++CoinDisjointCopy(const T* first, const T* last, ++ T* to) + { + CoinDisjointCopyN(first, static_cast<int>(last - first), to); + } +@@ -256,7 +256,7 @@ + alternative coding if USE_MEMCPY defined*/ + #ifndef COIN_USE_RESTRICT + template <class T> inline void +-CoinMemcpyN(register const T* from, const int size, register T* to) ++CoinMemcpyN(const T* from, const int size, T* to) + { + #ifndef _MSC_VER + #ifdef USE_MEMCPY +@@ -296,7 +296,7 @@ + throw CoinError("overlapping arrays", "CoinMemcpyN", ""); + #endif + +- for (register int n = size / 8; n > 0; --n, from += 8, to += 8) { ++ for (int n = size / 8; n > 0; --n, from += 8, to += 8) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; +@@ -343,8 +343,8 @@ + are copied at a time. The source array is given by its first and "after + last" entry; the target array is given by its first entry. */ + template <class T> inline void +-CoinMemcpy(register const T* first, register const T* last, +- register T* to) ++CoinMemcpy(const T* first, const T* last, ++ T* to) + { + CoinMemcpyN(first, static_cast<int>(last - first), to); + } +@@ -358,7 +358,7 @@ + Note JJF - the speed claim seems to be false on IA32 so I have added + CoinZero to allow for memset. */ + template <class T> inline void +-CoinFillN(register T* to, const int size, register const T value) ++CoinFillN(T* to, const int size, const T value) + { + if (size == 0) + return; +@@ -369,7 +369,7 @@ + "CoinFillN", ""); + #endif + #if 1 +- for (register int n = size / 8; n > 0; --n, to += 8) { ++ for (int n = size / 8; n > 0; --n, to += 8) { + to[0] = value; + to[1] = value; + to[2] = value; +@@ -413,7 +413,7 @@ + entries are filled at a time. The array is given by its first and "after + last" entry. */ + template <class T> inline void +-CoinFill(register T* first, register T* last, const T value) ++CoinFill(T* first, T* last, const T value) + { + CoinFillN(first, last - first, value); + } +@@ -427,7 +427,7 @@ + Note JJF - the speed claim seems to be false on IA32 so I have allowed + for memset as an alternative */ + template <class T> inline void +-CoinZeroN(register T* to, const int size) ++CoinZeroN(T* to, const int size) + { + #ifdef USE_MEMCPY + // Use memset - seems faster on Intel with gcc +@@ -448,7 +448,7 @@ + "CoinZeroN", ""); + #endif + #if 1 +- for (register int n = size / 8; n > 0; --n, to += 8) { ++ for (int n = size / 8; n > 0; --n, to += 8) { + to[0] = 0; + to[1] = 0; + to[2] = 0; +@@ -519,7 +519,7 @@ + entries are filled at a time. The array is given by its first and "after + last" entry. */ + template <class T> inline void +-CoinZero(register T* first, register T* last) ++CoinZero(T* first, T* last) + { + CoinZeroN(first, last - first); + } +@@ -545,7 +545,7 @@ + This function was introduced because for some reason compiler tend to + handle the <code>max()</code> function differently. */ + template <class T> inline T +-CoinMax(register const T x1, register const T x2) ++CoinMax(const T x1, const T x2) + { + return (x1 > x2) ? x1 : x2; + } +@@ -556,7 +556,7 @@ + This function was introduced because for some reason compiler tend to + handle the min() function differently. */ + template <class T> inline T +-CoinMin(register const T x1, register const T x2) ++CoinMin(const T x1, const T x2) + { + return (x1 < x2) ? x1 : x2; + } +@@ -578,7 +578,7 @@ + according to operator<. The array is given by a pointer to its first entry + and by its size. */ + template <class T> inline bool +-CoinIsSorted(register const T* first, const int size) ++CoinIsSorted(const T* first, const int size) + { + if (size == 0) + return true; +@@ -590,7 +590,7 @@ + #if 1 + // size1 is the number of comparisons to be made + const int size1 = size - 1; +- for (register int n = size1 / 8; n > 0; --n, first += 8) { ++ for (int n = size1 / 8; n > 0; --n, first += 8) { + if (first[8] < first[7]) return false; + if (first[7] < first[6]) return false; + if (first[6] < first[5]) return false; +@@ -627,7 +627,7 @@ + according to operator<. The array is given by its first and "after + last" entry. */ + template <class T> inline bool +-CoinIsSorted(register const T* first, register const T* last) ++CoinIsSorted(const T* first, const T* last) + { + return CoinIsSorted(first, static_cast<int>(last - first)); + } +@@ -638,7 +638,7 @@ + etc. For speed 8 entries are filled at a time. The array is given by a + pointer to its first entry and its size. */ + template <class T> inline void +-CoinIotaN(register T* first, const int size, register T init) ++CoinIotaN(T* first, const int size, T init) + { + if (size == 0) + return; +@@ -648,7 +648,7 @@ + throw CoinError("negative number of entries", "CoinIotaN", ""); + #endif + #if 1 +- for (register int n = size / 8; n > 0; --n, first += 8, init += 8) { ++ for (int n = size / 8; n > 0; --n, first += 8, init += 8) { + first[0] = init; + first[1] = init + 1; + first[2] = init + 2; +@@ -706,7 +706,7 @@ + integer array specified by the last two arguments (again, first and "after + last" entry). */ + template <class T> inline T * +-CoinDeleteEntriesFromArray(register T * arrayFirst, register T * arrayLast, ++CoinDeleteEntriesFromArray(T * arrayFirst, T * arrayLast, + const int * firstDelPos, const int * lastDelPos) + { + int delNum = static_cast<int>(lastDelPos - firstDelPos); +--- CoinUtils/src/CoinModelUseful2.cpp ++++ CoinUtils/src/CoinModelUseful2.cpp +@@ -917,8 +917,8 @@ + + int position=0; + int nEof=0; // Number of time send of string +- register int yystate; +- register int yyn; ++ int yystate; ++ int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; +@@ -936,12 +936,12 @@ + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; +- register short *yyssp; ++ short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; +- register YYSTYPE *yyvsp; ++ YYSTYPE *yyvsp; + + + +--- CoinUtils/src/CoinOslC.h ++++ CoinUtils/src/CoinOslC.h +@@ -34,30 +34,30 @@ + extern "C"{ + #endif + +-int c_ekkbtrn( register const EKKfactinfo *fact, ++int c_ekkbtrn( const EKKfactinfo *fact, + double *dwork1, + int * mpt,int first_nonzero); +-int c_ekkbtrn_ipivrw( register const EKKfactinfo *fact, ++int c_ekkbtrn_ipivrw( const EKKfactinfo *fact, + double *dwork1, + int * mpt, int ipivrw,int * spare); + +-int c_ekketsj( register /*const*/ EKKfactinfo *fact, ++int c_ekketsj( /*const*/ EKKfactinfo *fact, + double *dwork1, + int *mpt2, double dalpha, int orig_nincol, + int npivot, int *nuspikp, + const int ipivrw, int * spare); +-int c_ekkftrn( register const EKKfactinfo *fact, ++int c_ekkftrn( const EKKfactinfo *fact, + double *dwork1, + double * dpermu,int * mpt, int numberNonZero); + +-int c_ekkftrn_ft( register EKKfactinfo *fact, ++int c_ekkftrn_ft( EKKfactinfo *fact, + double *dwork1, int *mpt, int *nincolp); +-void c_ekkftrn2( register EKKfactinfo *fact, double *dwork1, ++void c_ekkftrn2( EKKfactinfo *fact, double *dwork1, + double * dpermu1,int * mpt1, int *nincolp, + double *dwork1_ft, int *mpt_ft, int *nincolp_ft); + +-int c_ekklfct( register EKKfactinfo *fact); +-int c_ekkslcf( register const EKKfactinfo *fact); ++int c_ekklfct( EKKfactinfo *fact); ++int c_ekkslcf( const EKKfactinfo *fact); + inline void c_ekkscpy(int n, const int *marr1,int *marr2) + { CoinMemcpyN(marr1,n,marr2);} + inline void c_ekkdcpy(int n, const double *marr1,double *marr2) +--- CoinUtils/src/CoinOslFactorization2.cpp ++++ CoinUtils/src/CoinOslFactorization2.cpp +@@ -20,9 +20,9 @@ + extern int ets_count; + extern int ets_check; + #endif +-#define COIN_REGISTER register ++#define COIN_REGISTER + #define COIN_REGISTER2 +-#define COIN_REGISTER3 register ++#define COIN_REGISTER3 + #ifdef COIN_USE_RESTRICT + # define COIN_RESTRICT2 __restrict + #else +--- CoinUtils/src/CoinOslFactorization3.cpp ++++ CoinUtils/src/CoinOslFactorization3.cpp +@@ -1378,7 +1378,7 @@ + } + } + } /* c_ekkmltf */ +-int c_ekklfct( register EKKfactinfo *fact) ++int c_ekklfct( EKKfactinfo *fact) + { + const int nrow = fact->nrow; + int ninbas = fact->xcsadr[nrow+1]-1; +@@ -2607,7 +2607,7 @@ + } + } + } /* c_ekkclcp */ +-int c_ekkslcf( register const EKKfactinfo *fact) ++int c_ekkslcf( const EKKfactinfo *fact) + { + int * hrow = fact->xeradr; + int * hcol = fact->xecadr; +--- CoinUtils/src/CoinPackedVectorBase.cpp ++++ CoinUtils/src/CoinPackedVectorBase.cpp +@@ -194,8 +194,8 @@ + double + CoinPackedVectorBase::oneNorm() const + { +- register double norm = 0.0; +- register const double* elements = getElements(); ++ double norm = 0.0; ++ const double* elements = getElements(); + for (int i = getNumElements() - 1; i >= 0; --i) { + norm += fabs(elements[i]); + } +@@ -224,8 +224,8 @@ + double + CoinPackedVectorBase::infNorm() const + { +- register double norm = 0.0; +- register const double* elements = getElements(); ++ double norm = 0.0; ++ const double* elements = getElements(); + for (int i = getNumElements() - 1; i >= 0; --i) { + norm = CoinMax(norm, fabs(elements[i])); + } +--- CoinUtils/src/CoinSearchTree.hpp ++++ CoinUtils/src/CoinSearchTree.hpp +@@ -153,8 +153,8 @@ + static inline const char* name() { return "CoinSearchTreeComparePreferred"; } + inline bool operator()(const CoinTreeSiblings* x, + const CoinTreeSiblings* y) const { +- register const CoinTreeNode* xNode = x->currentNode(); +- register const CoinTreeNode* yNode = y->currentNode(); ++ const CoinTreeNode* xNode = x->currentNode(); ++ const CoinTreeNode* yNode = y->currentNode(); + const BitVector128 xPref = xNode->getPreferred(); + const BitVector128 yPref = yNode->getPreferred(); + bool retval = true; +--- CoinUtils/src/CoinSimpFactorization.cpp ++++ CoinUtils/src/CoinSimpFactorization.cpp +@@ -2440,7 +2440,7 @@ + const int row=secRowOfU_[i]; + const int column=colOfU_[i]; + if ( denseVector_[column]==0.0 ) continue; +- register const double multiplier=denseVector_[column]*invOfPivots_[row]; ++ const double multiplier=denseVector_[column]*invOfPivots_[row]; + denseVector_[column]=0.0; + const int rowBeg=UrowStarts_[row]; + const int rowEnd=rowBeg+UrowLengths_[row]; diff --git a/external/curl/ExternalPackage_curl.mk b/external/curl/ExternalPackage_curl.mk index 8da569e3e0cf..3308074b363c 100644 --- a/external/curl/ExternalPackage_curl.mk +++ b/external/curl/ExternalPackage_curl.mk @@ -14,13 +14,13 @@ $(eval $(call gb_ExternalPackage_use_external_project,curl,curl)) ifneq ($(DISABLE_DYNLOADING),TRUE) ifeq ($(COM),MSC) -$(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).dll,builds/libcurl-vc12-$(if $(filter X86_64,$(CPUNAME)),x64,x86)-$(if $(MSVC_USE_DEBUG_RUNTIME),debug,release)-dll-ipv6-sspi-winssl/bin/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).dll)) +$(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).dll,builds/libcurl-vc12-$(if $(filter X86_64,$(CPUNAME)),x64,x86)-$(if $(MSVC_USE_DEBUG_RUNTIME),debug,release)-dll-ipv6-sspi-schannel/bin/libcurl$(if $(MSVC_USE_DEBUG_RUNTIME),_debug).dll)) else ifeq ($(OS),MACOSX) $(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl.4.dylib,lib/.libs/libcurl.4.dylib)) else ifeq ($(OS),AIX) $(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl.so,lib/.libs/libcurl.so.4)) else -$(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl.so.4,lib/.libs/libcurl.so.4.6.0)) +$(eval $(call gb_ExternalPackage_add_file,curl,$(LIBO_LIB_FOLDER)/libcurl.so.4,lib/.libs/libcurl.so.4.8.0)) endif endif # $(DISABLE_DYNLOADING) diff --git a/external/curl/ExternalProject_curl.mk b/external/curl/ExternalProject_curl.mk index b1029ea779e3..2bf98e2b2e3e 100644 --- a/external/curl/ExternalProject_curl.mk +++ b/external/curl/ExternalProject_curl.mk @@ -35,21 +35,22 @@ ifeq ($(SYSTEM_NSS),) curl_CPPFLAGS += -I$(call gb_UnpackedTarball_get_dir,nss)/dist/public/nss endif -# use --with-darwinssl on Mac OS X >10.5 and iOS to get a native UI for SSL certs for CMIS usage +# use --with-secure-transport on Mac OS X >10.5 and iOS to get a native UI for SSL certs for CMIS usage # use --with-nss only on platforms other than Mac OS X and iOS $(call gb_ExternalProject_get_state_target,curl,build): $(call gb_ExternalProject_run,build,\ ./configure \ - $(if $(filter iOS MACOSX,$(OS)),\ - --with-darwinssl,\ - $(if $(ENABLE_NSS),--with-nss$(if $(SYSTEM_NSS),,="$(call gb_UnpackedTarball_get_dir,nss)/dist/out"),--without-nss)) \ + $(if $(filter IOS MACOSX,$(OS)),\ + --with-secure-transport,\ + $(if $(ENABLE_NSS),--with-nss$(if $(SYSTEM_NSS),,="$(call gb_UnpackedTarball_get_dir,nss)/dist/out") --with-nss-deprecated,--without-nss)) \ --without-ssl --without-gnutls --without-polarssl --without-cyassl --without-axtls --without-mbedtls \ --enable-ftp --enable-http --enable-ipv6 \ --without-libidn2 --without-libpsl --without-librtmp \ --without-libssh2 --without-metalink --without-nghttp2 \ --without-libssh --without-brotli \ --without-ngtcp2 --without-quiche \ - --disable-ares \ + --without-zstd --without-hyper --without-gsasl --without-gssapi \ + --disable-mqtt --disable-ares \ --disable-dict --disable-file --disable-gopher --disable-imap \ --disable-ldap --disable-ldaps --disable-manual --disable-pop3 \ --disable-rtsp --disable-smb --disable-smtp --disable-telnet \ diff --git a/external/curl/curl-7.26.0_win-proxy.patch b/external/curl/curl-7.26.0_win-proxy.patch index 5361433a917b..c5498c3fdebb 100644 --- a/external/curl/curl-7.26.0_win-proxy.patch +++ b/external/curl/curl-7.26.0_win-proxy.patch @@ -31,7 +31,7 @@ +{ + int bufSize; + char *out = NULL; -+ if(wStr != NULL) { ++ if(wStr) { + bufSize = WideCharToMultiByte( + CP_ACP, 0, wStr, -1, NULL, 0, NULL, NULL); + out = (char *)malloc(bufSize * sizeof(char)); @@ -63,10 +63,10 @@ + ieNoProxy = wstrToCstr(ieProxyConfig->lpszProxyBypass); + + /* Convert the ieNoProxy into a proper no_proxy value */ -+ if(NULL != ieNoProxy) { ++ if(ieNoProxy) { + no_proxy = strdup(ieNoProxy); + pos = strpbrk(no_proxy, "; "); -+ while(NULL != pos) { ++ while(pos) { + no_proxy[pos-no_proxy] = ','; + pos = strpbrk(no_proxy, "; "); + } @@ -77,9 +77,9 @@ + char *tok; + char *saveptr; + -+ if(NULL != ieProxy) { ++ if(ieProxy) { + tok = strtok_s(ieProxy, ";", &saveptr); -+ if(strchr(tok, '=') == NULL) { ++ if(!strchr(tok, '=')) { + proxy = strdup(ieProxy); + } + else { @@ -90,7 +90,7 @@ + } + tok = strtok_s(NULL, ";", &saveptr); + } -+ while(NULL != tok); ++ while(tok); + } + } + } @@ -114,7 +114,7 @@ @@ -4663,6 +4739,7 @@ } if(proxy) - infof(conn->data, "Uses proxy env variable %s == '%s'\n", envp, proxy); + infof(data, "Uses proxy env variable %s == '%s'", envp, proxy); +#endif /* WIN32 */ return proxy; diff --git a/external/curl/curl-msvc-disable-protocols.patch.1 b/external/curl/curl-msvc-disable-protocols.patch.1 index c8747a5fcc1d..a6d06c69b004 100644 --- a/external/curl/curl-msvc-disable-protocols.patch.1 +++ b/external/curl/curl-msvc-disable-protocols.patch.1 @@ -2,18 +2,19 @@ disable protocols nobody needs in MSVC build --- curl/lib/config-win32.h.orig 2017-08-09 16:43:29.464000000 +0200 +++ curl/lib/config-win32.h 2017-08-09 16:47:38.549200000 +0200 -@@ -733,4 +733,19 @@ +@@ -733,4 +733,20 @@ # define ENABLE_IPV6 1 #endif +#define CURL_DISABLE_DICT 1 +#define CURL_DISABLE_FILE 1 -+//#undef CURL_DISABLE_FTP ++#undef CURL_DISABLE_FTP +#define CURL_DISABLE_GOPHER 1 -+//#undef CURL_DISABLE_HTTP ++#undef CURL_DISABLE_HTTP +#define CURL_DISABLE_IMAP 1 +#define CURL_DISABLE_LDAP 1 +#define CURL_DISABLE_LDAPS 1 ++#define CURL_DISABLE_MQTT 1 +#define CURL_DISABLE_POP3 1 +#define CURL_DISABLE_RTSP 1 +#define CURL_DISABLE_SMB 1 diff --git a/external/curl/curl-nss.patch.1 b/external/curl/curl-nss.patch.1 index 69fde5f7f236..d4dad7eba77e 100644 --- a/external/curl/curl-nss.patch.1 +++ b/external/curl/curl-nss.patch.1 @@ -1,9 +1,9 @@ diff -ur curl.org/configure curl/configure --- curl.org/configure 2016-03-13 15:14:07.177000076 +0100 +++ curl/configure 2016-03-13 15:16:44.132000076 +0100 -@@ -24009,7 +24009,7 @@ - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Using hard-wired libraries and compilation flags for NSS." >&5 - $as_echo "$as_me: WARNING: Using hard-wired libraries and compilation flags for NSS." >&2;} +@@ -28216,7 +28216,7 @@ + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Using hard-wired libraries and compilation flags for NSS." >&5 + printf "%s\n" "$as_me: WARNING: Using hard-wired libraries and compilation flags for NSS." >&2;} addld="-L$OPT_NSS/lib" - addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4" + addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lnssutil3" diff --git a/external/curl/zlib.patch.0 b/external/curl/zlib.patch.0 index 189e820d1afa..e0f579f8675a 100644 --- a/external/curl/zlib.patch.0 +++ b/external/curl/zlib.patch.0 @@ -1,22 +1,22 @@ --- configure +++ configure -@@ -20709,7 +20709,6 @@ +@@ -22699,7 +22699,6 @@ clean_CPPFLAGS=$CPPFLAGS clean_LDFLAGS=$LDFLAGS clean_LIBS=$LIBS -ZLIB_LIBS="" # Check whether --with-zlib was given. - if test "${with_zlib+set}" = set; then : -@@ -20718,6 +20719,7 @@ + if test ${with_zlib+y} +@@ -22709,6 +22708,7 @@ if test "$OPT_ZLIB" = "no" ; then + ZLIB_LIBS="" - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zlib disabled" >&5 - $as_echo "$as_me: WARNING: zlib disabled" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: zlib disabled" >&5 + printf "%s\n" "$as_me: WARNING: zlib disabled" >&2;} else -@@ -20725,6 +20725,21 @@ +@@ -22716,6 +22716,21 @@ OPT_ZLIB="" fi @@ -38,8 +38,8 @@ if test -z "$OPT_ZLIB" ; then if test -n "$PKG_CONFIG"; then -@@ -21005,6 +21020,7 @@ - $as_echo "$as_me: found both libz and libz.h header" >&6;} +@@ -23011,6 +23026,7 @@ + printf "%s\n" "$as_me: found both libz and libz.h header" >&6;} curl_zlib_msg="enabled" fi + fi @@ -54,8 +54,8 @@ clean_LIBS=$LIBS -ZLIB_LIBS="" AC_ARG_WITH(zlib, - AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH]) - AC_HELP_STRING([--without-zlib],[disable use of zlib]), + AS_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH]) + AS_HELP_STRING([--without-zlib],[disable use of zlib]), [OPT_ZLIB="$withval"]) if test "$OPT_ZLIB" = "no" ; then diff --git a/external/expat/expat-winapi.patch b/external/expat/expat-winapi.patch index b33c12b83b4c..7eae7d5d6139 100644 --- a/external/expat/expat-winapi.patch +++ b/external/expat/expat-winapi.patch @@ -11,3 +11,14 @@ # endif #endif /* not defined XML_STATIC */ +--- misc/expat-2.1.0/lib/xmlparse.c 2021-05-23 16:56:25.000000000 +0100 ++++ misc/build/expat-2.1.0/lib/xmlparse.c 2021-05-25 12:42:11.997173600 +0100 +@@ -64,6 +64,8 @@ + #endif + + #ifdef _WIN32 ++# undef HAVE_GETRANDOM ++# undef HAVE_SYSCALL_GETRANDOM + /* force stdlib to define rand_s() */ + # if ! defined(_CRT_RAND_S) + # define _CRT_RAND_S diff --git a/external/gpgmepp/ExternalProject_gpgmepp.mk b/external/gpgmepp/ExternalProject_gpgmepp.mk index 452f922750d6..dac2fad1361b 100644 --- a/external/gpgmepp/ExternalProject_gpgmepp.mk +++ b/external/gpgmepp/ExternalProject_gpgmepp.mk @@ -40,7 +40,7 @@ $(call gb_ExternalProject_get_state_target,gpgmepp,build): $(call gb_Executable_ $(if $(ENABLE_DEBUG),$(gb_DEBUG_CFLAGS)) \ $(if $(filter $(true),$(gb_SYMBOL)),$(gb_DEBUGINFO_FLAGS))' \ --host=$(gb_ExternalProject_gpgmepp_host) \ - RC='windres -O COFF --target=$(gb_ExternalProject_gpgmepp_target) --preprocessor='\''$(call gb_Executable_get_target,cpp) -+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)'\' \ + RC='windres -O COFF --target=$(gb_ExternalProject_gpgmepp_target) --preprocessor=$(call gb_Executable_get_target,cpp) --preprocessor-arg=-+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)' \ MAKE=$(MAKE) \ && $(MAKE) \ ) diff --git a/external/graphite/StaticLibrary_graphite.mk b/external/graphite/StaticLibrary_graphite.mk index 8c16482ba11b..9eeff041dc28 100644 --- a/external/graphite/StaticLibrary_graphite.mk +++ b/external/graphite/StaticLibrary_graphite.mk @@ -44,7 +44,6 @@ $(eval $(call gb_StaticLibrary_add_generated_exception_objects,graphite,\ UnpackedTarball/graphite/src/gr_segment \ UnpackedTarball/graphite/src/gr_slot \ UnpackedTarball/graphite/src/json \ - UnpackedTarball/graphite/src/CachedFace \ UnpackedTarball/graphite/src/CmapCache \ UnpackedTarball/graphite/src/Code \ UnpackedTarball/graphite/src/Collider \ @@ -60,9 +59,6 @@ $(eval $(call gb_StaticLibrary_add_generated_exception_objects,graphite,\ UnpackedTarball/graphite/src/NameTable \ UnpackedTarball/graphite/src/Pass \ UnpackedTarball/graphite/src/Position \ - UnpackedTarball/graphite/src/SegCache \ - UnpackedTarball/graphite/src/SegCacheEntry \ - UnpackedTarball/graphite/src/SegCacheStore \ UnpackedTarball/graphite/src/Segment \ UnpackedTarball/graphite/src/Silf \ UnpackedTarball/graphite/src/Slot \ diff --git a/external/graphite/UnpackedTarball_graphite.mk b/external/graphite/UnpackedTarball_graphite.mk index a162d172b795..0abd4b657d91 100644 --- a/external/graphite/UnpackedTarball_graphite.mk +++ b/external/graphite/UnpackedTarball_graphite.mk @@ -11,12 +11,4 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,graphite)) $(eval $(call gb_UnpackedTarball_set_tarball,graphite,$(GRAPHITE_TARBALL))) -$(eval $(call gb_UnpackedTarball_set_patchlevel,graphite,0)) - -$(eval $(call gb_UnpackedTarball_add_patches,graphite,\ - external/graphite/graphite2.issue1115.patch.1 \ - external/graphite/graphite2.win64.patch.1 \ - external/graphite/ubsan.patch \ -)) - # vim: set noet sw=4 ts=4: diff --git a/external/graphite/graphite2.issue1115.patch.1 b/external/graphite/graphite2.issue1115.patch.1 deleted file mode 100644 index 454114bb32c9..000000000000 --- a/external/graphite/graphite2.issue1115.patch.1 +++ /dev/null @@ -1,22 +0,0 @@ ---- graphite/src/Code.cpp -+++ graphite/src/Code.cpp -@@ -175,8 +175,8 @@ Machine::Code::Code(bool is_constraint, - bytecode_end, - pre_context, - rule_length, -- silf.numClasses(), -- face.glyphs().numAttrs(), -+ static_cast<uint16>(silf.numClasses()), -+ static_cast<uint16>(face.glyphs().numAttrs()), - face.numFeatures(), - {1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,255, -@@ -184,7 +184,7 @@ Machine::Code::Code(bool is_constraint, - 1,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, -- 0,0,0,0,0,0,0, silf.numUser()} -+ 0,0,0,0,0,0,0, static_cast<byte>(silf.numUser())} - }; - - decoder dec(lims, *this, pt); diff --git a/external/graphite/graphite2.win64.patch.1 b/external/graphite/graphite2.win64.patch.1 deleted file mode 100644 index d7cf11e63189..000000000000 --- a/external/graphite/graphite2.win64.patch.1 +++ /dev/null @@ -1,60 +0,0 @@ -diff -urN graphite2-1.3.4.orig/src/inc/json.h graphite2-1.3.4/src/inc/json.h ---- graphite2-1.3.4.orig/src/inc/json.h 2015-12-22 14:25:46.403566441 +0100 -+++ graphite2-1.3.4/src/inc/json.h 2015-12-22 14:26:13.439722846 +0100 -@@ -85,6 +85,9 @@ - json & operator << (string) throw(); - json & operator << (number) throw(); - json & operator << (integer) throw(); -+#ifdef _WIN64 -+ json & operator << (size_t) throw(); -+#endif - json & operator << (long unsigned int d) throw(); - json & operator << (boolean) throw(); - json & operator << (_null_t) throw(); -diff -urN graphite2-1.3.4.orig/src/inc/Main.h graphite2-1.3.4/src/inc/Main.h ---- graphite2-1.3.4.orig/src/inc/Main.h 2015-12-22 14:25:46.399566417 +0100 -+++ graphite2-1.3.4/src/inc/Main.h 2015-12-22 14:26:13.439722846 +0100 -@@ -25,6 +25,9 @@ - of the License or (at your option) any later version. - */ - #pragma once -+#ifdef _WIN32 -+#pragma warning(disable: 4510 4610) -+#endif - - #include <cstdlib> - #include "graphite2/Types.h" -diff -urN graphite2-1.3.4.orig/src/json.cpp graphite2-1.3.4/src/json.cpp ---- graphite2-1.3.4.orig/src/json.cpp 2015-12-22 14:25:46.399566417 +0100 -+++ graphite2-1.3.4/src/json.cpp 2015-12-22 14:26:13.439722846 +0100 -@@ -133,6 +133,9 @@ - } - json & json::operator << (json::integer d) throw() { context(seq); fprintf(_stream, "%ld", d); return *this; } - json & json::operator << (long unsigned d) throw() { context(seq); fprintf(_stream, "%ld", d); return *this; } -+#ifdef _WIN64 -+json & json::operator << (size_t d) throw() { context(seq); fprintf(_stream, "%ld", d); return *this; } -+#endif - json & json::operator << (json::boolean b) throw() { context(seq); fputs(b ? "true" : "false", _stream); return *this; } - json & json::operator << (json::_null_t) throw() { context(seq); fputs("null",_stream); return *this; } - -diff -urN graphite2-1.3.4.orig/src/Pass.cpp graphite2-1.3.4/src/Pass.cpp ---- graphite2-1.3.4.orig/src/Pass.cpp 2015-12-22 14:25:46.399566417 +0100 -+++ graphite2-1.3.4/src/Pass.cpp 2015-12-22 14:26:13.439722846 +0100 -@@ -568,7 +568,7 @@ - if (r->rule->preContext > fsm.slots.context()) - continue; - *fsm.dbgout << json::flat << json::object -- << "id" << r->rule - m_rules -+ << "id" << static_cast<size_t>(r->rule - m_rules) - << "failed" << true - << "input" << json::flat << json::object - << "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, -r->rule->preContext))) -@@ -582,7 +582,7 @@ - void Pass::dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * const last_slot) const - { - *fsm.dbgout << json::item << json::flat << json::object -- << "id" << &r - m_rules -+ << "id" << static_cast<size_t>(&r - m_rules) - << "failed" << false - << "input" << json::flat << json::object - << "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, 0))) diff --git a/external/graphite/ubsan.patch b/external/graphite/ubsan.patch deleted file mode 100644 index 86039de4e1c8..000000000000 --- a/external/graphite/ubsan.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- src/TtfUtil.cpp -+++ src/TtfUtil.cpp -@@ -1247,7 +1247,7 @@ - void * GlyfLookup(const void * pGlyf, size_t nGlyfOffset, size_t nTableLen) - { - const uint8 * pByte = reinterpret_cast<const uint8 *>(pGlyf); -- if (nGlyfOffset + pByte < pByte || nGlyfOffset + sizeof(Sfnt::Glyph) >= nTableLen) -+ if (nGlyfOffset > nTableLen || sizeof(Sfnt::Glyph) >= nTableLen - nGlyfOffset) - return NULL; - return const_cast<uint8 *>(pByte + nGlyfOffset); - } ---- src/gr_face.cpp -+++ src/gr_face.cpp -@@ -87,7 +87,7 @@ - - Face *res = new Face(appFaceHandle, *ops); - if (res && load_face(*res, faceOptions)) -- return static_cast<gr_face *>(res); -+ return reinterpret_cast<gr_face *>(res); - - delete res; - return 0; -@@ -195,7 +195,7 @@ - - void gr_face_destroy(gr_face *face) - { -- delete face; -+ delete static_cast<Face *>(face); - } - - ---- src/gr_font.cpp -+++ src/gr_font.cpp -@@ -50,7 +50,7 @@ - if (face == 0) return 0; - - Font * const res = new Font(ppm, *face, appFontHandle, font_ops); -- return static_cast<gr_font*>(res); -+ return reinterpret_cast<gr_font*>(res); - } - - gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, gr_advance_fn getAdvance, const gr_face * face/*needed for scaling*/) -@@ -61,7 +61,7 @@ - - void gr_font_destroy(gr_font *font) - { -- delete font; -+ delete static_cast<Font *>(font); - } - - ---- src/inc/Code.h -+++ src/inc/Code.h -@@ -162,7 +162,7 @@ - { - if (_code && !_own) - { -- _code += dist / sizeof(instr); -+ _code += dist / int(sizeof(instr)); - _data += dist; - } - } diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk index a5416b7ee078..a0ab0b9af4c5 100644 --- a/external/icu/UnpackedTarball_icu.mk +++ b/external/icu/UnpackedTarball_icu.mk @@ -40,6 +40,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\ external/icu/char8_t.patch \ external/icu/CVE-2018-18928.patch.2 \ external/icu/b7d08bc04a4296982fcef8b6b8a354a9e4e7afca.patch.2 \ + external/icu/cec7de7a390dd6907b0ea0feb4488ed3934ee71d.patch.2 \ + external/icu/e450fa50fc242282551f56b941dc93b9a8a0bcbb.patch.2 \ )) $(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict)) diff --git a/external/icu/cec7de7a390dd6907b0ea0feb4488ed3934ee71d.patch.2 b/external/icu/cec7de7a390dd6907b0ea0feb4488ed3934ee71d.patch.2 new file mode 100644 index 000000000000..1ded56abf524 --- /dev/null +++ b/external/icu/cec7de7a390dd6907b0ea0feb4488ed3934ee71d.patch.2 @@ -0,0 +1,94 @@ +From cec7de7a390dd6907b0ea0feb4488ed3934ee71d Mon Sep 17 00:00:00 2001 +From: Frank Tang <ftang@chromium.org> +Date: Tue, 16 Mar 2021 22:08:29 -0700 +Subject: [PATCH] ICU-21537 Fix invalid free by long locale name + +Do not free baseName if it is pointing to fullNameBuffer. + +Better Fix +--- + icu4c/source/common/locid.cpp | 9 +++++---- + icu4c/source/test/intltest/collationtest.cpp | 10 ++++++++++ + 2 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp +index 5d604350ecd..e16fbb724a4 100644 +--- a/icu4c/source/common/locid.cpp ++++ b/icu4c/source/common/locid.cpp +@@ -254,7 +254,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Locale) + + Locale::~Locale() + { +- if (baseName != fullName) { ++ if ((baseName != fullName) && (baseName != fullNameBuffer)) { + uprv_free(baseName); + } + baseName = NULL; +@@ -466,7 +466,7 @@ Locale& Locale::operator=(const Locale& other) { + } + + Locale& Locale::operator=(Locale&& other) U_NOEXCEPT { +- if (baseName != fullName) uprv_free(baseName); ++ if ((baseName != fullName) && (baseName != fullNameBuffer)) uprv_free(baseName); + if (fullName != fullNameBuffer) uprv_free(fullName); + + if (other.fullName == other.fullNameBuffer) { +@@ -1850,7 +1850,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize) + { + fIsBogus = FALSE; + /* Free our current storage */ +- if (baseName != fullName) { ++ if ((baseName != fullName) && (baseName != fullNameBuffer)) { + uprv_free(baseName); + } + baseName = NULL; +@@ -1886,6 +1886,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize) + uloc_getName(localeID, fullName, sizeof(fullNameBuffer), &err); + + if(err == U_BUFFER_OVERFLOW_ERROR || length >= (int32_t)sizeof(fullNameBuffer)) { ++ U_ASSERT(baseName == nullptr); + /*Go to heap for the fullName if necessary*/ + fullName = (char *)uprv_malloc(sizeof(char)*(length + 1)); + if(fullName == 0) { +@@ -2039,7 +2040,7 @@ Locale::hashCode() const + void + Locale::setToBogus() { + /* Free our current storage */ +- if(baseName != fullName) { ++ if((baseName != fullName) && (baseName != fullNameBuffer)) { + uprv_free(baseName); + } + baseName = NULL; +diff --git a/icu4c/source/test/intltest/collationtest.cpp b/icu4c/source/test/intltest/collationtest.cpp +index de51eece5c4..4f1fee9375e 100644 +--- a/icu4c/source/test/intltest/collationtest.cpp ++++ b/icu4c/source/test/intltest/collationtest.cpp +@@ -78,6 +78,7 @@ class CollationTest : public IntlTest { + void TestRootElements(); + void TestTailoredElements(); + void TestDataDriven(); ++ void TestLongLocale(); + + private: + void checkFCD(const char *name, CollationIterator &ci, CodePointIterator &cpi); +@@ -148,6 +149,7 @@ void CollationTest::runIndexedTest(int32_t index, UBool exec, const char *&name, + TESTCASE_AUTO(TestRootElements); + TESTCASE_AUTO(TestTailoredElements); + TESTCASE_AUTO(TestDataDriven); ++ TESTCASE_AUTO(TestLongLocale); + TESTCASE_AUTO_END; + } + +@@ -1852,4 +1854,12 @@ void CollationTest::TestDataDriven() { + } + } + ++void CollationTest::TestLongLocale() { ++ IcuTestErrorCode errorCode(*this, "TestLongLocale"); ++ Locale longLocale("sie__1G_C_CEIE_CEZCX_CSUE_E_EIESZNI2_GB_LM_LMCSUE_LMCSX_" ++ "LVARIANT_MMCSIE_STEU_SU1GCEIE_SU6G_SU6SU6G_U_UBGE_UC_" ++ "UCEZCSI_UCIE_UZSIU_VARIANT_X@collation=bcs-ukvsz"); ++ LocalPointer<Collator> coll(Collator::createInstance(longLocale, errorCode)); ++} ++ + #endif // !UCONFIG_NO_COLLATION diff --git a/external/icu/e450fa50fc242282551f56b941dc93b9a8a0bcbb.patch.2 b/external/icu/e450fa50fc242282551f56b941dc93b9a8a0bcbb.patch.2 new file mode 100644 index 000000000000..4709cd8c37fd --- /dev/null +++ b/external/icu/e450fa50fc242282551f56b941dc93b9a8a0bcbb.patch.2 @@ -0,0 +1,39 @@ +From e450fa50fc242282551f56b941dc93b9a8a0bcbb Mon Sep 17 00:00:00 2001 +From: Frank Tang <ftang@chromium.org> +Date: Tue, 13 Apr 2021 15:16:50 -0700 +Subject: [PATCH] ICU-21587 Fix memory bug w/ baseName + +Edge cases not fixed in assign and move assign operator +while the locale is long and call setKeywordValue with incorrect +keyword/values. +--- + icu4c/source/common/locid.cpp | 11 +++++++++-- + icu4c/source/test/intltest/loctest.cpp | 26 ++++++++++++++++++++++++++ + icu4c/source/test/intltest/loctest.h | 2 ++ + 3 files changed, 37 insertions(+), 2 deletions(-) + +diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp +index 02cd82a7b8e..3c6e5b06690 100644 +--- a/icu4c/source/common/locid.cpp ++++ b/icu4c/source/common/locid.cpp +@@ -469,14 +469,18 @@ Locale& Locale::operator=(Locale&& other) U_NOEXCEPT { + if ((baseName != fullName) && (baseName != fullNameBuffer)) uprv_free(baseName); + if (fullName != fullNameBuffer) uprv_free(fullName); + +- if (other.fullName == other.fullNameBuffer) { ++ if (other.fullName == other.fullNameBuffer || other.baseName == other.fullNameBuffer) { + uprv_strcpy(fullNameBuffer, other.fullNameBuffer); ++ } ++ if (other.fullName == other.fullNameBuffer) { + fullName = fullNameBuffer; + } else { + fullName = other.fullName; + } + +- if (other.baseName == other.fullName) { ++ if (other.baseName == other.fullNameBuffer) { ++ baseName = fullNameBuffer; ++ } else if (other.baseName == other.fullName) { + baseName = fullName; + } else { + baseName = other.baseName; diff --git a/external/libassuan/ExternalProject_libassuan.mk b/external/libassuan/ExternalProject_libassuan.mk index 83d79a520988..9237c35a5d31 100644 --- a/external/libassuan/ExternalProject_libassuan.mk +++ b/external/libassuan/ExternalProject_libassuan.mk @@ -30,11 +30,12 @@ $(call gb_ExternalProject_get_state_target,libassuan,build): $(call gb_Executabl --disable-shared \ --disable-doc \ $(if $(verbose),--disable-silent-rules,--enable-silent-rules) \ + CFLAGS="$(CFLAGS) -D__STDC__=1" \ CXXFLAGS="$(CXXFLAGS)" \ GPG_ERROR_CFLAGS="$(GPG_ERROR_CFLAGS)" \ GPG_ERROR_LIBS="$(GPG_ERROR_LIBS)" \ --host=$(gb_ExternalProject_libassuan_host) \ - RC='windres -O COFF --target=$(gb_ExternalProject_libassuan_target) --preprocessor='\''$(call gb_Executable_get_target,cpp) -+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)'\' \ + RC='windres -O COFF --target=$(gb_ExternalProject_libassuan_target) --preprocessor=$(call gb_Executable_get_target,cpp) --preprocessor-arg=-+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)' \ MAKE=$(MAKE) \ && $(MAKE) \ ) diff --git a/external/libgpg-error/ExternalProject_libgpg-error.mk b/external/libgpg-error/ExternalProject_libgpg-error.mk index 1fcd63180e20..e5155aad94c1 100644 --- a/external/libgpg-error/ExternalProject_libgpg-error.mk +++ b/external/libgpg-error/ExternalProject_libgpg-error.mk @@ -28,7 +28,7 @@ $(call gb_ExternalProject_get_state_target,libgpg-error,build): $(call gb_Execut --disable-doc \ --disable-tests \ --host=$(gb_ExternalProject_libgpg-error_host) \ - RC='windres -O COFF --target=$(gb_ExternalProject_libgpg-error_target) --preprocessor='\''$(call gb_Executable_get_target,cpp) -+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)'\' \ + RC='windres -O COFF --target=$(gb_ExternalProject_libgpg-error_target) --preprocessor=$(call gb_Executable_get_target,cpp) --preprocessor-arg=-+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)' \ && $(MAKE) \ ) else diff --git a/external/libjpeg-turbo/UnpackedTarball_libjpeg-turbo.mk b/external/libjpeg-turbo/UnpackedTarball_libjpeg-turbo.mk index a99df67bb011..5440d16ecfc1 100644 --- a/external/libjpeg-turbo/UnpackedTarball_libjpeg-turbo.mk +++ b/external/libjpeg-turbo/UnpackedTarball_libjpeg-turbo.mk @@ -19,6 +19,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libjpeg-turbo,\ external/libjpeg-turbo/jpeg-turbo.build.patch.1 \ $(if $(filter WNT,$(OS)),external/libjpeg-turbo/jpeg-turbo.win_build.patch.1) \ external/libjpeg-turbo/ubsan.patch \ + external/libjpeg-turbo/c76f4a08263b0cea40d2967560ac7c21f6959079.patch.1 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libjpeg-turbo/c76f4a08263b0cea40d2967560ac7c21f6959079.patch.1 b/external/libjpeg-turbo/c76f4a08263b0cea40d2967560ac7c21f6959079.patch.1 new file mode 100644 index 000000000000..cc3da737e7b0 --- /dev/null +++ b/external/libjpeg-turbo/c76f4a08263b0cea40d2967560ac7c21f6959079.patch.1 @@ -0,0 +1,38 @@ +From c76f4a08263b0cea40d2967560ac7c21f6959079 Mon Sep 17 00:00:00 2001 +From: DRC <information@libjpeg-turbo.org> +Date: Thu, 5 Dec 2019 13:12:28 -0600 +Subject: [PATCH] Huffman enc.: Fix very rare local buffer overrun + +... detected by ASan. This is a similar issue to the issue that was +fixed with 402a715f82313384ef4606660c32d8678c79f197. Apparently it is +possible to create a malformed JPEG image that exceeds the Huffman +encoder's 256-byte local buffer when attempting to losslessly tranform +the image. That makes sense, given that it was necessary to extend the +Huffman decoder's local buffer to 512 bytes in order to handle all +pathological cases (refer to 0463f7c9aad060fcd56e98d025ce16185279e2bc.) + +Since this issue affected only lossless transformation, a workflow that +isn't generally exposed to arbitrary data exploits, and since the +overrun did not overflow the stack (i.e. it did not result in a segfault +or other user-visible issue, and valgrind didn't even detect it), it did +not likely pose a security risk. + +Fixes #392 +--- + ChangeLog.md | 10 ++++++++++ + jchuff.c | 2 +- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/jchuff.c b/jchuff.c +index 206958e2f..cb05055d9 100644 +--- a/jchuff.c ++++ b/jchuff.c +@@ -432,7 +432,7 @@ dump_buffer(working_state *state) + * scanning order-- 1, 8, 16, etc.), then this will produce an encoded block + * larger than 200 bytes. + */ +-#define BUFSIZE (DCTSIZE2 * 4) ++#define BUFSIZE (DCTSIZE2 * 8) + + #define LOAD_BUFFER() { \ + if (state->free_in_buffer < BUFSIZE) { \ diff --git a/external/liborcus/inc/pch/precompiled_orcus.hxx b/external/liborcus/inc/pch/precompiled_orcus.hxx deleted file mode 100644 index 28e1bc8119d8..000000000000 --- a/external/liborcus/inc/pch/precompiled_orcus.hxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - */ - -/* - This file has been autogenerated by update_pch.sh. It is possible to edit it - manually (such as when an include file has been moved/renamed/removed). All such - manual changes will be rewritten by the next run of update_pch.sh (which presumably - also fixes all possible problems, so it's usually better to use it). - - Generated on 2020-02-01 12:22:35 using: - ./bin/update_pch external/liborcus orcus --cutoff=1 --exclude:system --include:module --include:local - - If after updating build fails, use the following command to locate conflicting headers: - ./bin/update_pch_bisect ./external/liborcus/inc/pch/precompiled_orcus.hxx "make external/liborcus.build" --find-conflicts -*/ - -#if PCH_LEVEL >= 1 -#include <algorithm> -#include <cassert> -#include <codecvt> -#include <cstdio> -#include <cstdlib> -#include <cstring> -#include <deque> -#include <fstream> -#include <functional> -#include <iostream> -#include <iterator> -#include <limits> -#include <locale> -#include <map> -#include <memory> -#include <ostream> -#include <sstream> -#include <string> -#include <unordered_map> -#include <unordered_set> -#include <vector> -#include <boost/current_function.hpp> -#include <boost/filesystem.hpp> -#include <boost/iostreams/filter/gzip.hpp> -#include <boost/iostreams/filtering_stream.hpp> -#include <boost/optional.hpp> -#include <boost/pool/object_pool.hpp> -#endif // PCH_LEVEL >= 1 -#if PCH_LEVEL >= 2 -#endif // PCH_LEVEL >= 2 -#if PCH_LEVEL >= 3 -#include <mdds/global.hpp> -#include <mdds/sorted_string_map.hpp> -#include <orcus/config.hpp> -#include <orcus/css_document_tree.hpp> -#include <orcus/css_parser.hpp> -#include <orcus/css_selector.hpp> -#include <orcus/csv_parser.hpp> -#include <orcus/dom_tree.hpp> -#include <orcus/exception.hpp> -#include <orcus/format_detection.hpp> -#include <orcus/global.hpp> -#include <orcus/info.hpp> -#include <orcus/interface.hpp> -#include <orcus/json_document_tree.hpp> -#include <orcus/json_global.hpp> -#include <orcus/json_parser.hpp> -#include <orcus/json_structure_tree.hpp> -#include <orcus/measurement.hpp> -#include <orcus/orcus_csv.hpp> -#include <orcus/orcus_gnumeric.hpp> -#include <orcus/orcus_import_ods.hpp> -#include <orcus/orcus_import_xlsx.hpp> -#include <orcus/orcus_json.hpp> -#include <orcus/orcus_ods.hpp> -#include <orcus/orcus_xls_xml.hpp> -#include <orcus/orcus_xlsx.hpp> -#include <orcus/orcus_xml.hpp> -#include <orcus/parser_base.hpp> -#include <orcus/parser_global.hpp> -#include <orcus/pstring.hpp> -#include <orcus/sax_ns_parser.hpp> -#include <orcus/sax_parser.hpp> -#include <orcus/sax_parser_base.hpp> -#include <orcus/sax_token_parser.hpp> -#include <orcus/spreadsheet/export_interface.hpp> -#include <orcus/spreadsheet/import_interface.hpp> -#include <orcus/spreadsheet/import_interface_pivot.hpp> -#include <orcus/spreadsheet/import_interface_view.hpp> -#include <orcus/spreadsheet/styles.hpp> -#include <orcus/spreadsheet/types.hpp> -#include <orcus/stream.hpp> -#include <orcus/string_pool.hpp> -#include <orcus/threaded_sax_token_parser.hpp> -#include <orcus/tokens.hpp> -#include <orcus/xml_namespace.hpp> -#include <orcus/xml_structure_tree.hpp> -#include <orcus/yaml_document_tree.hpp> -#include <orcus/yaml_parser.hpp> -#include <orcus/zip_archive.hpp> -#include <orcus/zip_archive_stream.hpp> -#endif // PCH_LEVEL >= 3 -#if PCH_LEVEL >= 4 -#endif // PCH_LEVEL >= 4 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/external/libxml2/libxml2-config.patch.1 b/external/libxml2/libxml2-config.patch.1 index 8c28fb6a7806..5a2ef1485e92 100644 --- a/external/libxml2/libxml2-config.patch.1 +++ b/external/libxml2/libxml2-config.patch.1 @@ -18,9 +18,9 @@ Hack the xml2-config to return paths into WORKDIR. +exec_prefix=${WORKDIR}/UnpackedTarball/libxml2 +includedir=${WORKDIR}/UnpackedTarball/libxml2/include +libdir=${WORKDIR}/UnpackedTarball/libxml2/.libs + cflags= + libs= - usage() - { @@ -67,7 +72,8 @@ ;; diff --git a/external/libxml2/libxml2-global-symbols.patch b/external/libxml2/libxml2-global-symbols.patch index 49ee73731562..cfec9c530281 100644 --- a/external/libxml2/libxml2-global-symbols.patch +++ b/external/libxml2/libxml2-global-symbols.patch @@ -14,8 +14,8 @@ LIBXML2_2.6.32 { @@ -2231,3 +2231,43 @@ - xmlHashDefaultDeallocator; - } LIBXML2_2.9.1; + xmlPopOutputCallbacks; + } LIBXML2_2.9.8; +# HACK: export global variable accessor functions (globals.h) +LIBXML2_GLOBAL_VARIABLES { diff --git a/external/libxslt/UnpackedTarball_libxslt.mk b/external/libxslt/UnpackedTarball_libxslt.mk index b035e99f0a79..eae318ef74b9 100644 --- a/external/libxslt/UnpackedTarball_libxslt.mk +++ b/external/libxslt/UnpackedTarball_libxslt.mk @@ -19,7 +19,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,libxslt,\ external/libxslt/libxslt-msvc.patch.2 \ external/libxslt/libxslt-1.1.26-memdump.patch \ external/libxslt/rpath.patch.0 \ - external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 b/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 deleted file mode 100644 index f82c2e4f77ee..000000000000 --- a/external/libxslt/e2584eed1c84c18f16e42188c30d2c3d8e3e8853.patch.1 +++ /dev/null @@ -1,69 +0,0 @@ -From e2584eed1c84c18f16e42188c30d2c3d8e3e8853 Mon Sep 17 00:00:00 2001 -From: Chun-wei Fan <fanchunwei@src.gnome.org> -Date: Tue, 12 Nov 2019 17:37:05 +0800 -Subject: [PATCH] win32: Add configuration for profiler - -Without this the generated xsltconfig.h will not be complete as there -will be a configuration variable that is left in the header, breaking -builds. - -This will allow one to enable or disable profiler support in Windows -builds, and the default is to enable this. ---- - win32/configure.js | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/win32/configure.js b/win32/configure.js -index 56694cce..12c99f30 100644 ---- a/win32/configure.js -+++ b/win32/configure.js -@@ -47,6 +47,7 @@ var withIconv = true; - var withZlib = false; - var withCrypto = true; - var withModules = false; -+var withProfiler = true; - /* Win32 build options. */ - var dirSep = "\\"; - var compiler = "msvc"; -@@ -106,6 +107,7 @@ function usage() - txt += " zlib: Use zlib library (" + (withZlib? "yes" : "no") + ")\n"; - txt += " crypto: Enable Crypto support (" + (withCrypto? "yes" : "no") + ")\n"; - txt += " modules: Enable Module support (" + (withModules? "yes" : "no") + ")\n"; -+ txt += " profiler: Enable Profiler support (" + (withProfiler? "yes" : "no") + ")\n"; - txt += "\nWin32 build options, default value given in parentheses:\n\n"; - txt += " compiler: Compiler to be used [msvc|mingw] (" + compiler + ")\n"; - txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n"; -@@ -192,6 +194,7 @@ function discoverVersion() - vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0")); - vf.WriteLine("WITH_CRYPTO=" + (withCrypto? "1" : "0")); - vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0")); -+ vf.WriteLine("WITH_PROFILER=" + (withProfiler? "1" : "0")); - vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0")); - vf.WriteLine("STATIC=" + (buildStatic? "1" : "0")); - vf.WriteLine("PREFIX=" + buildPrefix); -@@ -240,6 +243,8 @@ function configureXslt() - of.WriteLine(s.replace(/\@WITH_DEBUGGER\@/, withDebugger? "1" : "0")); - } else if (s.search(/\@WITH_MODULES\@/) != -1) { - of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0")); -+ } else if (s.search(/\@WITH_PROFILER\@/) != -1) { -+ of.WriteLine(s.replace(/\@WITH_PROFILER\@/, withProfiler? "1" : "0")); - } else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) { - of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL")); - } else -@@ -343,6 +348,8 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { - withCrypto = strToBool(arg.substring(opt.length + 1, arg.length)); - else if (opt == "modules") - withModules = strToBool(arg.substring(opt.length + 1, arg.length)); -+ else if (opt == "profiler") -+ withProfiler = strToBool(arg.substring(opt.length + 1, arg.length)); - else if (opt == "compiler") - compiler = arg.substring(opt.length + 1, arg.length); - else if (opt == "cruntime") -@@ -477,6 +484,7 @@ txtOut += " Use iconv: " + boolToStr(withIconv) + "\n"; - txtOut += " With zlib: " + boolToStr(withZlib) + "\n"; - txtOut += " Crypto: " + boolToStr(withCrypto) + "\n"; - txtOut += " Modules: " + boolToStr(withModules) + "\n"; -+txtOut += " Profiler: " + boolToStr(withProfiler) + "\n"; - txtOut += "\n"; - txtOut += "Win32 build configuration\n"; - txtOut += "-------------------------\n"; diff --git a/external/libxslt/rpath.patch.0 b/external/libxslt/rpath.patch.0 index 78c4859251df..798bccec750e 100644 --- a/external/libxslt/rpath.patch.0 +++ b/external/libxslt/rpath.patch.0 @@ -7,4 +7,4 @@ +hardcode_libdir_flag_spec= ;; - netbsd*) + netbsd* | netbsdelf*-gnu) diff --git a/external/nss/ExternalProject_nss.mk b/external/nss/ExternalProject_nss.mk index b270ebd9fc74..59135e7dc1f8 100644 --- a/external/nss/ExternalProject_nss.mk +++ b/external/nss/ExternalProject_nss.mk @@ -20,6 +20,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalExecuta $(call gb_ExternalProject_run,build,\ $(if $(MSVC_USE_DEBUG_RUNTIME),USE_DEBUG_RTL=1,BUILD_OPT=1) \ OS_TARGET=WIN95 \ + NSS_DISABLE_AVX2=1 \ $(if $(filter X86_64,$(CPUNAME)),USE_64=1) \ LIB="$(ILIB)" \ XCFLAGS="-arch:SSE $(SOLARINC)" \ diff --git a/external/nss/UnpackedTarball_nss.mk b/external/nss/UnpackedTarball_nss.mk index fd0cfa56e1d3..e1b42122fa25 100644 --- a/external/nss/UnpackedTarball_nss.mk +++ b/external/nss/UnpackedTarball_nss.mk @@ -22,8 +22,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\ external/nss/nss.vs2015.patch \ external/nss/nss.vs2015.pdb.patch \ external/nss/macos-dlopen.patch.0 \ - $(if $(filter iOS,$(OS)), \ - external/nss/nss-ios.patch) \ + $(if $(filter ANDROID,$(OS)), \ + external/nss/nss-android.patch.1) \ $(if $(filter MSC-INTEL,$(COM)-$(CPUNAME)), \ external/nss/nss.cygwin64.in32bit.patch) \ $(if $(filter WNT,$(OS)), \ diff --git a/external/nss/nss-android.patch.1 b/external/nss/nss-android.patch.1 index 50c549303604..bc574bc1ec71 100644 --- a/external/nss/nss-android.patch.1 +++ b/external/nss/nss-android.patch.1 @@ -8,9 +8,9 @@ diff -ur nss.org/nspr/build/autoconf/config.sub nss/nspr/build/autoconf/config.s +if test $1 = "arm-unknown-linux-androideabi"; then echo $1; exit; fi +if test $1 = "i686-pc-linux-android"; then echo $1; exit; fi + - # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). - # Here we must recognize all the valid KERNEL-OS combinations. - maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` + # Split fields of configuration type + # shellcheck disable=SC2162 + IFS="-" read field1 field2 field3 field4 <<EOF diff -ur nss.org/nspr/configure nss/nspr/configure --- nss.org/nspr/configure 2017-09-07 15:29:45.018246359 +0200 +++ nss/nspr/configure 2017-09-07 15:31:47.604075663 +0200 diff --git a/external/nss/nss-ios.patch b/external/nss/nss-ios.patch deleted file mode 100644 index 9d4af2c724e9..000000000000 --- a/external/nss/nss-ios.patch +++ /dev/null @@ -1,112 +0,0 @@ ---- a/a/nspr/config/autoconf.mk.in -+++ a/a/nspr/config/autoconf.mk.in -@@ -67,7 +67,7 @@ - MSC_VER = @MSC_VER@ - AR = @AR@ - AR_FLAGS = @AR_FLAGS@ --LD = @LD@ -+LD = echo - RANLIB = @RANLIB@ - PERL = @PERL@ - RC = @RC@ ---- a/a/nspr/configure -+++ a/a/nspr/configure -@@ -755,7 +755,7 @@ - OBJDIR='$(OBJDIR_NAME)' - OBJDIR_NAME=. - OBJDIR_SUFFIX=OBJ --NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' -+NSINSTALL=${NSINSTALL?'$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'} - NOSUCHFILE=/no-such-file - LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)' - LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)' -@@ -3060,7 +3060,7 @@ - LIB_SUFFIX=a - DLL_SUFFIX=so - ASM_SUFFIX=s --MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@' -+MKSHLIB='touch $@; echo' - PR_MD_ASFILES= - PR_MD_CSRCS= - PR_MD_ARCH_DIR=unix -@@ -3904,7 +3904,7 @@ - DSO_CFLAGS=-fPIC - DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @__________________________________________________OOO/$@ -headerpad_max_install_names' - _OPTIMIZE_FLAGS=-O2 -- MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' -+ MKSHLIB=touch $@ - STRIP="$STRIP -x -S" - DLL_SUFFIX=dylib - USE_PTHREADS=1 ---- a/a/nss/coreconf/ruleset.mk -+++ a/a/nss/coreconf/ruleset.mk -@@ -68,7 +68,7 @@ - endif - - ifeq ($(MKPROG),) -- MKPROG = $(CC) -+ MKPROG = touch $@; echo - endif - - # ---- a/a/nss/coreconf/Darwin.mk -+++ a/a/nss/coreconf/Darwin.mk -@@ -124,7 +124,7 @@ - DSO_LDOPTS += --coverage - endif - --MKSHLIB = $(CC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS) -+MKSHLIB = touch $@; echo - DLL_SUFFIX = dylib - ifdef MAPFILE - MKSHLIB += -exported_symbols_list $(MAPFILE) ---- a/a/nss/coreconf/UNIX.mk -+++ a/a/nss/coreconf/UNIX.mk -@@ -21,10 +21,14 @@ - - ifdef BUILD_TREE - NSINSTALL_DIR = $(BUILD_TREE)/nss -+ifndef NSINSTALL - NSINSTALL = $(BUILD_TREE)/nss/nsinstall -+endif - else - NSINSTALL_DIR = $(CORE_DEPTH)/coreconf/nsinstall -+ifndef NSINSTALL - NSINSTALL = $(NSINSTALL_DIR)/$(OBJDIR_NAME)/nsinstall -+endif - endif - - MKDEPEND_DIR = $(CORE_DEPTH)/coreconf/mkdepend ---- a/a/nspr/pr/include/md/_darwin.h -+++ a/a/nspr/pr/include/md/_darwin.h -@@ -26,6 +26,8 @@ - #define _PR_SI_ARCHITECTURE "ppc" - #elif defined(__arm__) - #define _PR_SI_ARCHITECTURE "arm" -+#elif defined(__arm64__) -+#define _PR_SI_ARCHITECTURE "arm64" - #elif defined(__aarch64__) - #define _PR_SI_ARCHITECTURE "aarch64" - #else ---- a/a/nspr/pr/src/Makefile.in -+++ a/a/nspr/pr/src/Makefile.in -@@ -180,7 +180,7 @@ - endif - - ifeq ($(OS_TARGET),MacOSX) --OS_LIBS = -framework CoreServices -framework CoreFoundation -+OS_LIBS = -framework CoreFoundation - endif - - EXTRA_LIBS += $(OS_LIBS) ---- a/a/nss/cmd/shlibsign/sign.sh -+++ a/a/nss/cmd/shlibsign/sign.sh -@@ -2,6 +2,8 @@ - # 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/. -+ -+exit 0 - - # arguments: - # 1: full path to DIST/OBJDIR (parent dir of "lib") diff --git a/external/openssl/UnpackedTarball_openssl.mk b/external/openssl/UnpackedTarball_openssl.mk index ad600cce1412..e7fca1116545 100644 --- a/external/openssl/UnpackedTarball_openssl.mk +++ b/external/openssl/UnpackedTarball_openssl.mk @@ -22,6 +22,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,openssl,\ external/openssl/openssl-3650-masm.patch.1 \ external/openssl/openssl-fixbuild.patch.1 \ external/openssl/openssl-1.0.2k-cve-2020-1971.patch.1 \ + external/openssl/ccb0a11145ee72b042d10593a64eaf9e8a55ec12.patch.1 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/openssl/ccb0a11145ee72b042d10593a64eaf9e8a55ec12.patch.1 b/external/openssl/ccb0a11145ee72b042d10593a64eaf9e8a55ec12.patch.1 new file mode 100644 index 000000000000..cf809750ecfb --- /dev/null +++ b/external/openssl/ccb0a11145ee72b042d10593a64eaf9e8a55ec12.patch.1 @@ -0,0 +1,56 @@ +From ccb0a11145ee72b042d10593a64eaf9e8a55ec12 Mon Sep 17 00:00:00 2001 +From: Matt Caswell <matt@openssl.org> +Date: Tue, 17 Aug 2021 14:41:48 +0100 +Subject: [PATCH] Fix a read buffer overrun in X509_CERT_AUX_print() + +This is a backport of commit c5dc9ab965f to 1.0.2. That commit fixed +the same bug but in master/1.1.1 it is in the function X509_aux_print(). +The original commit had the following description: + +Fix a read buffer overrun in X509_aux_print(). + +The ASN1_STRING_get0_data(3) manual explitely cautions the reader +that the data is not necessarily NUL-terminated, and the function +X509_alias_set1(3) does not sanitize the data passed into it in any +way either, so we must assume the return value from X509_alias_get0(3) +is merely a byte array and not necessarily a string in the sense +of the C language. + +I found this bug while writing manual pages for X509_print_ex(3) +and related functions. Theo Buehler <tb@openbsd.org> checked my +patch to fix the same bug in LibreSSL, see + +http://cvsweb.openbsd.org/src/lib/libcrypto/asn1/t_x509a.c#rev1.9 + +As an aside, note that the function still produces incomplete and +misleading results when the data contains a NUL byte in the middle +and that error handling is consistently absent throughout, even +though the function provides an "int" return value obviously intended +to be 1 for success and 0 for failure, and even though this function +is called by another function that also wants to return 1 for success +and 0 for failure and even does so in many of its code paths, though +not in others. But let's stay focussed. Many things would be nice +to have in the wide wild world, but a buffer overflow must not be +allowed to remain in our backyard. + +CVE-2021-3712 + +Reviewed-by: Paul Dale <pauli@openssl.org> +--- + crypto/asn1/t_x509a.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/crypto/asn1/t_x509a.c b/crypto/asn1/t_x509a.c +index d1b897a469fd..b1bc9d0cd28b 100644 +--- a/crypto/asn1/t_x509a.c ++++ b/crypto/asn1/t_x509a.c +@@ -104,7 +104,8 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) + } else + BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); + if (aux->alias) +- BIO_printf(out, "%*sAlias: %s\n", indent, "", aux->alias->data); ++ BIO_printf(out, "%*sAlias: %.*s\n", indent, "", aux->alias->length, ++ aux->alias->data); + if (aux->keyid) { + BIO_printf(out, "%*sKey Id: ", indent, ""); + for (i = 0; i < aux->keyid->length; i++) diff --git a/external/pdfium/Library_pdfium.mk b/external/pdfium/Library_pdfium.mk index 3b37143c4599..52dc752068a8 100644 --- a/external/pdfium/Library_pdfium.mk +++ b/external/pdfium/Library_pdfium.mk @@ -63,7 +63,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_actionhandler \ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annotiterator \ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_customaccess \ - UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_fieldaction \ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_filewriteadapter \ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_helpers \ UnpackedTarball/pdfium/fpdfsdk/fpdf_annot \ @@ -82,6 +81,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_interactiveform \ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_renderpage \ UnpackedTarball/pdfium/fpdfsdk/fpdf_signature \ + UnpackedTarball/pdfium/constants/annotation_common \ + UnpackedTarball/pdfium/constants/appearance \ + UnpackedTarball/pdfium/constants/form_fields \ + UnpackedTarball/pdfium/constants/page_object \ + UnpackedTarball/pdfium/constants/stream_dict_common \ + UnpackedTarball/pdfium/constants/transparency \ )) # fdrm @@ -95,7 +100,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_checkbox \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_combobox \ - UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_formfiller \ + UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_formfield \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_interactiveformfiller \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_listbox \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_pushbutton \ @@ -103,7 +108,8 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_textfield \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_button \ UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_textobject \ - UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_privatedata \ + UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_fieldaction \ + UnpackedTarball/pdfium/fpdfsdk/formfiller/cffl_perwindowdata \ )) # fpdfapi @@ -287,11 +293,11 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_pagerendercontext \ UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfuncdib \ UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfunc \ + UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_basedcs \ )) # fpdfdoc $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ - UnpackedTarball/pdfium/core/fpdfdoc/cline \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_aaction \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_action \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_annot \ @@ -312,18 +318,17 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_nametree \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_numbertree \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_pagelabel \ - UnpackedTarball/pdfium/core/fpdfdoc/cpdf_variabletext \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_viewerpreferences \ UnpackedTarball/pdfium/core/fpdfdoc/cpvt_fontmap \ - UnpackedTarball/pdfium/core/fpdfdoc/cpvt_generateap \ UnpackedTarball/pdfium/core/fpdfdoc/cpvt_wordinfo \ - UnpackedTarball/pdfium/core/fpdfdoc/csection \ - UnpackedTarball/pdfium/core/fpdfdoc/ctypeset \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_structelement \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_structtree \ - UnpackedTarball/pdfium/core/fpdfdoc/cba_fontmap \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_color_utils \ UnpackedTarball/pdfium/core/fpdfdoc/cpdf_icon \ + UnpackedTarball/pdfium/core/fpdfdoc/cpdf_bafontmap \ + UnpackedTarball/pdfium/core/fpdfdoc/cpdf_generateap \ + UnpackedTarball/pdfium/core/fpdfdoc/cpvt_section \ + UnpackedTarball/pdfium/core/fpdfdoc/cpvt_variabletext \ )) # fpdftext @@ -354,7 +359,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_SymbolDict \ UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_TrdProc \ UnpackedTarball/pdfium/core/fxcodec/gif/cfx_gif \ - UnpackedTarball/pdfium/core/fxcodec/gif/cfx_lzwdecompressor \ + UnpackedTarball/pdfium/core/fxcodec/gif/lzw_decompressor \ UnpackedTarball/pdfium/core/fxcodec/cfx_codec_memory \ UnpackedTarball/pdfium/core/fxcodec/fax/faxmodule \ UnpackedTarball/pdfium/core/fxcodec/scanlinedecoder \ @@ -364,7 +369,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_DocumentContext \ UnpackedTarball/pdfium/core/fxcodec/basic/basicmodule \ UnpackedTarball/pdfium/core/fxcodec/flate/flatemodule \ - UnpackedTarball/pdfium/core/fxcodec/icc/iccmodule \ + UnpackedTarball/pdfium/core/fxcodec/icc/icc_transform \ UnpackedTarball/pdfium/core/fxcodec/jbig2/jbig2_decoder \ UnpackedTarball/pdfium/core/fxcodec/jpeg/jpeg_common \ )) @@ -392,7 +397,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscustomproperty \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssdeclaration \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssenumvalue \ - UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssexttextbuf \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssnumbervalue \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_csspropertyholder \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssrulecollection \ @@ -402,10 +406,11 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssstyleselector \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssstylesheet \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_csssyntaxparser \ - UnpackedTarball/pdfium/core/fxcrt/css/cfx_csstextbuf \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssvalue \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssvaluelist \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssvaluelistparser \ + UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssinputtextbuf \ + UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssoutputtextbuf \ UnpackedTarball/pdfium/core/fxcrt/cfx_datetime \ UnpackedTarball/pdfium/core/fxcrt/bytestring \ UnpackedTarball/pdfium/core/fxcrt/cfx_binarybuf \ @@ -467,7 +472,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxge/cfx_gemodule \ UnpackedTarball/pdfium/core/fxge/cfx_graphstate \ UnpackedTarball/pdfium/core/fxge/cfx_graphstatedata \ - UnpackedTarball/pdfium/core/fxge/cfx_pathdata \ + UnpackedTarball/pdfium/core/fxge/cfx_path \ UnpackedTarball/pdfium/core/fxge/cfx_renderdevice \ UnpackedTarball/pdfium/core/fxge/cfx_substfont \ UnpackedTarball/pdfium/core/fxge/cfx_unicodeencoding \ @@ -495,9 +500,8 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_caret \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_combo_box \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_edit \ - UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_edit_ctrl \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_edit_impl \ - UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_icon \ + UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_sbbutton \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_list_box \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_cbbutton \ UnpackedTarball/pdfium/fpdfsdk/pwl/cpwl_cblistbox \ @@ -625,12 +629,14 @@ $(eval $(call gb_Library_add_generated_cobjects,pdfium,\ UnpackedTarball/pdfium/third_party/freetype/src/src/truetype/truetype \ UnpackedTarball/pdfium/third_party/freetype/src/src/type1/type1 \ UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftdebug \ + UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftfstype \ )) endif ifneq ($(OS),WNT) $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_posix \ + UnpackedTarball/pdfium/core/fxcrt/fx_folder_posix \ )) endif @@ -646,8 +652,10 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxge/win32/cps_printer_driver \ UnpackedTarball/pdfium/core/fxge/win32/ctext_only_printer_driver \ UnpackedTarball/pdfium/core/fxge/win32/cwin32_platform \ + UnpackedTarball/pdfium/core/fxge/win32/cfx_psfonttracker \ UnpackedTarball/pdfium/core/fxge/cfx_windowsrenderdevice \ UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_windows \ + UnpackedTarball/pdfium/core/fxcrt/fx_folder_windows \ UnpackedTarball/pdfium/third_party/base/win/win_util \ UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_windowsrenderdevice \ )) @@ -665,7 +673,7 @@ ifeq ($(OS),MACOSX) # fxge $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxge/apple/fx_apple_platform \ - UnpackedTarball/pdfium/core/fxge/apple/fx_mac_impl \ + UnpackedTarball/pdfium/core/fxge/apple/fx_apple_impl \ UnpackedTarball/pdfium/core/fxge/apple/fx_quartz_device \ )) @@ -690,7 +698,7 @@ endif ifeq ($(OS),LINUX) # fxge $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ - UnpackedTarball/pdfium/core/fxge/fx_ge_linux \ + UnpackedTarball/pdfium/core/fxge/linux/fx_linux_impl \ )) endif diff --git a/external/pdfium/README b/external/pdfium/README index c1719cf0a152..0a146d2e74de 100644 --- a/external/pdfium/README +++ b/external/pdfium/README @@ -8,6 +8,8 @@ https://pdfium.googlesource.com/pdfium/ How to update the tarball: version=$(git for-each-ref|grep chromium/|tail -n 1|sed 's|.*/||') +git checkout --track origin/chromium/$version +gclient sync git archive --prefix=pdfium/ --format=tar origin/chromium/${version} > pdfium-${version}.tar (cd ..; tar --append --file pdfium/pdfium-${version}.tar pdfium/third_party/freetype/src/include/ pdfium/third_party/freetype/src/src/) bzip2 pdfium-${version}.tar diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1 index 7cf1021938f5..60283ac63c74 100644 --- a/external/pdfium/build.patch.1 +++ b/external/pdfium/build.patch.1 @@ -37,14 +37,96 @@ index 0fb627ba8..dda1fc8bc 100644 : span(container.data(), container.size()) {} template < typename Container, +--- a/core/fxge/dib/cfx_cmyk_to_srgb.cpp 2020-09-10 17:32:37.165872018 +0200 ++++ b/core/fxge/dib/cfx_cmyk_to_srgb.cpp 2020-09-10 17:33:15.870395738 +0200 +@@ -1740,10 +1740,12 @@ + uint8_t y1 = static_cast<int>(y * 255.f + rounding_offset); + uint8_t k1 = static_cast<int>(k * 255.f + rounding_offset); + ++#ifndef _WIN32 + DCHECK_EQ(c1, FXSYS_roundf(c * 255)); + DCHECK_EQ(m1, FXSYS_roundf(m * 255)); + DCHECK_EQ(y1, FXSYS_roundf(y * 255)); + DCHECK_EQ(k1, FXSYS_roundf(k * 255)); ++#endif + + uint8_t r; + uint8_t g; +diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp b/core/fxcodec/jpx/cjpx_decoder.cpp +index c66985a7f..817f81dfa 100644 --- a/core/fxcodec/jpx/cjpx_decoder.cpp +++ b/core/fxcodec/jpx/cjpx_decoder.cpp -@@ -70,7 +70,7 @@ Optional<OpjImageRgbData> alloc_rgb(size_t size) { +@@ -71,7 +71,7 @@ Optional<OpjImageRgbData> alloc_rgb(size_t size) { if (!data.b) - return {}; + return pdfium::nullopt; - return data; + return std::move(data); } void sycc_to_rgb(int offset, +diff --git a/core/fdrm/fx_crypt_aes.cpp b/core/fdrm/fx_crypt_aes.cpp +index f2170220b..ede18f581 100644 +--- a/core/fdrm/fx_crypt_aes.cpp ++++ b/core/fdrm/fx_crypt_aes.cpp +@@ -437,7 +437,7 @@ const unsigned int D3[256] = { + (block[0] ^= *keysched++, block[1] ^= *keysched++, block[2] ^= *keysched++, \ + block[3] ^= *keysched++) + #define MOVEWORD(i) (block[i] = newstate[i]) +-#define MAKEWORD(i) \ ++#define FMAKEWORD(i) \ + (newstate[i] = (E0[(block[i] >> 24) & 0xFF] ^ \ + E1[(block[(i + C1) % Nb] >> 16) & 0xFF] ^ \ + E2[(block[(i + C2) % Nb] >> 8) & 0xFF] ^ \ +@@ -458,10 +458,10 @@ void aes_encrypt_nb_4(CRYPT_aes_context* ctx, unsigned int* block) { + unsigned int newstate[4]; + for (i = 0; i < ctx->Nr - 1; i++) { + ADD_ROUND_KEY_4(); +- MAKEWORD(0); +- MAKEWORD(1); +- MAKEWORD(2); +- MAKEWORD(3); ++ FMAKEWORD(0); ++ FMAKEWORD(1); ++ FMAKEWORD(2); ++ FMAKEWORD(3); + MOVEWORD(0); + MOVEWORD(1); + MOVEWORD(2); +@@ -478,10 +478,10 @@ void aes_encrypt_nb_4(CRYPT_aes_context* ctx, unsigned int* block) { + MOVEWORD(3); + ADD_ROUND_KEY_4(); + } +-#undef MAKEWORD ++#undef FMAKEWORD + #undef LASTWORD + +-#define MAKEWORD(i) \ ++#define FMAKEWORD(i) \ + (newstate[i] = (D0[(block[i] >> 24) & 0xFF] ^ \ + D1[(block[(i + C1) % Nb] >> 16) & 0xFF] ^ \ + D2[(block[(i + C2) % Nb] >> 8) & 0xFF] ^ \ +@@ -502,10 +502,10 @@ void aes_decrypt_nb_4(CRYPT_aes_context* ctx, unsigned int* block) { + unsigned int newstate[4]; + for (i = 0; i < ctx->Nr - 1; i++) { + ADD_ROUND_KEY_4(); +- MAKEWORD(0); +- MAKEWORD(1); +- MAKEWORD(2); +- MAKEWORD(3); ++ FMAKEWORD(0); ++ FMAKEWORD(1); ++ FMAKEWORD(2); ++ FMAKEWORD(3); + MOVEWORD(0); + MOVEWORD(1); + MOVEWORD(2); +@@ -522,7 +522,7 @@ void aes_decrypt_nb_4(CRYPT_aes_context* ctx, unsigned int* block) { + MOVEWORD(3); + ADD_ROUND_KEY_4(); + } +-#undef MAKEWORD ++#undef FMAKEWORD + #undef LASTWORD + + void aes_setup(CRYPT_aes_context* ctx, const unsigned char* key, int keylen) { diff --git a/external/pdfium/ubsan.patch b/external/pdfium/ubsan.patch index 8610e24f2828..bc9868244275 100644 --- a/external/pdfium/ubsan.patch +++ b/external/pdfium/ubsan.patch @@ -1,9 +1,9 @@ --- core/fxcrt/string_data_template.cpp +++ core/fxcrt/string_data_template.cpp @@ -82,7 +82,8 @@ void StringDataTemplate<CharType>::CopyContentsAt(size_t offset, - ASSERT(nLen >= 0); - ASSERT(offset + nLen <= m_nAllocLength); - + DCHECK_GE(offset, 0); + DCHECK_GE(nLen, 0); + DCHECK_LE(offset + nLen, m_nAllocLength); - memcpy(m_String + offset, pStr, nLen * sizeof(CharType)); + if (nLen != 0) + memcpy(m_String + offset, pStr, nLen * sizeof(CharType)); diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx index 0c011731c1d4..359c15ae78bc 100644 --- a/hwpfilter/source/htags.cxx +++ b/hwpfilter/source/htags.cxx @@ -19,6 +19,9 @@ #include "precompile.h" +#include <o3tl/char16_t2wchar_t.hxx> +#include <unotools/tempfile.hxx> + #include <string.h> #include "hwplib.h" @@ -108,27 +111,20 @@ void OlePicture::Read(HWPFile & hwpf) delete [] data; return; } - FILE *fp; - char tname[200]; - wchar_t wtname[200]; - tmpnam(tname); - if (nullptr == (fp = fopen(tname, "wb"))) - { - delete [] data; - return; - } - fwrite(data, size, 1, fp); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + + SvFileStream aOutputStream(aTempFile.GetURL(), StreamMode::WRITE); + aOutputStream.WriteBytes(data, size); delete [] data; - fclose(fp); - MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200); - if( StgOpenStorage(wtname, nullptr, + aOutputStream.Close(); + if( StgOpenStorage(o3tl::toW(aTempFile.GetFileName().getStr()), nullptr, STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, nullptr, 0, &pis) != S_OK ) { pis = nullptr; - unlink(tname); return; } - unlink(tname); #else hwpf.SkipBlock(size); #endif diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index 2ceefc481c2f..9599aaa46ded 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -241,6 +241,7 @@ void HWPFile::ReadParaList(std::vector < HWPPara* > &aplist) aplist.push_back(spNode.release()); spNode.reset( new HWPPara ); } + pfailedlist.push_back(std::move(spNode)); } void HWPFile::ReadParaList(std::vector< std::unique_ptr<HWPPara> > &aplist, unsigned char flag) @@ -274,6 +275,7 @@ void HWPFile::ReadParaList(std::vector< std::unique_ptr<HWPPara> > &aplist, unsi aplist.push_back(std::move(spNode)); spNode.reset( new HWPPara ); } + pfailedlist.push_back(std::move(spNode)); } void HWPFile::TagsRead() diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index 88e2151a5c9a..539c1b401c45 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -284,6 +284,10 @@ class DLLEXPORT HWPFile std::vector<std::unique_ptr<ColumnInfo>> columnlist; // paragraph list std::vector<std::unique_ptr<HWPPara>> plist; + // keep paragraph's that failed to load until + // import is complete to avoid dangling references + // elsewhere + std::vector<std::unique_ptr<HWPPara>> pfailedlist; // floating box list std::vector<FBox*> blist; // embedded picture list(tag datas) diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index dea71b5ea4e9..c4b63e9d6f57 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -515,62 +515,28 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) if( prop->flag >> 18 & 0x01 ) { padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, "fillimage%d", buf))); - if( !prop->pictype ) + + EmPicture *emp = nullptr; + if (prop->pictype && strlen(prop->szPatternFile) > 3) + emp = hwpfile.GetEmPictureByName(prop->szPatternFile); + if (!emp) { padd( "xlink:href", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str()))); + padd( "xlink:type", sXML_CDATA, "simple"); + padd( "xlink:show", sXML_CDATA, "embed"); + padd( "xlink:actuate", sXML_CDATA, "onLoad"); } - else - { - EmPicture *emp = nullptr; - if ( strlen( prop->szPatternFile ) > 3) - emp = hwpfile.GetEmPictureByName(prop->szPatternFile); - if( emp ) - { - char filename[128+17+9]; - char dirname[128]; - int fd; -#ifdef _WIN32 - GetTempPathA(sizeof(dirname), dirname); - sprintf(filename, "%s%s",dirname, emp->name); - if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 ) -#else - strcpy(dirname, "/tmp/"); - sprintf(filename, "%s%s", dirname, emp->name); - if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 ) -#endif - { - size_t nWritten = write(fd, emp->data.get(), emp->size); - OSL_VERIFY(nWritten == emp->size); - close(fd); - } -#ifdef _WIN32 - int j; - for(j = 0 ; j < static_cast<int>(strlen( dirname )) ; j++) - { - if( dirname[j] == '\\' ) buf[j] = '/'; - else buf[j] = dirname[j]; - } - buf[j] = '\0'; - sprintf(filename, "file:///%s%s",buf, emp->name ); -#else - sprintf(filename, "file://%s%s",dirname, emp->name ); -#endif - padd( "xlink:href", sXML_CDATA, ascii(filename)); - } - else - { - padd( "xlink:href", sXML_CDATA, - reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str()))); - } - - } - padd( "xlink:type", sXML_CDATA, "simple"); - padd( "xlink:show", sXML_CDATA, "embed"); - padd( "xlink:actuate", sXML_CDATA, "onLoad"); rstartEl( "draw:fill-image", mxList.get()); mxList->clear(); + if (emp) + { + rstartEl("office:binary-data", mxList.get()); + std::shared_ptr<char> pStr(base64_encode_string(emp->data.get(), emp->size), Free<char>()); + rchars(ascii(pStr.get())); + rendEl("office:binary-data"); + } rendEl( "draw:fill-image"); } /* If there is a gradient, when a bitmap file is present, this is the first. */ diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 71858daa617e..0c132acf3a43 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -13,7 +13,6 @@ #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/WordType.hpp> -#include <o3tl/cppunittraitshelper.hxx> #include <unotest/bootstrapfixturebase.hxx> #include <unicode/uversion.h> diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx index ce363acbc4e2..198585b6c14e 100644 --- a/i18nutil/source/utility/unicode.cxx +++ b/i18nutil/source/utility/unicode.cxx @@ -750,6 +750,34 @@ OString unicode::getExemplarLanguageForUScriptCode(UScriptCode eScript) sRet = "sog"; break; #endif +#if (U_ICU_VERSION_MAJOR_NUM >= 64) + case USCRIPT_ELYMAIC: + sRet = "arc-Elym"; + break; + case USCRIPT_NYIAKENG_PUACHUE_HMONG: + sRet = "hmn-Hmnp"; // macrolanguage code + break; + case USCRIPT_NANDINAGARI: + sRet = "sa-Nand"; + break; + case USCRIPT_WANCHO: + sRet = "nnp-Wcho"; + break; +#endif +#if (U_ICU_VERSION_MAJOR_NUM >= 66) + case USCRIPT_CHORASMIAN: + sRet = "xco-Chrs"; + break; + case USCRIPT_DIVES_AKURU: + sRet = "dv-Diak"; + break; + case USCRIPT_KHITAN_SMALL_SCRIPT: + sRet = "zkt-Kits"; + break; + case USCRIPT_YEZIDI: + sRet = "kmr-Yezi"; + break; +#endif } return sRet; } diff --git a/include/o3tl/cppunittraitshelper.hxx b/include/o3tl/cppunittraitshelper.hxx index d9f75a61b4c8..2a6fb8836238 100644 --- a/include/o3tl/cppunittraitshelper.hxx +++ b/include/o3tl/cppunittraitshelper.hxx @@ -12,6 +12,7 @@ #include <sal/config.h> +#include <cstdint> #include <string> #include <cppunit/TestAssert.h> @@ -19,7 +20,7 @@ // ostream << char16_t is deleted since C++20 (but just keep outputting numeric values): template <> inline std::string CppUnit::assertion_traits<char16_t>::toString(char16_t const& x) { - return assertion_traits<unsigned>::toString(unsigned(x)); + return assertion_traits<std::uint_least16_t>::toString(std::uint_least16_t(x)); } #endif diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index 3e7b9599aea0..fdf5527f9766 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -266,6 +266,8 @@ #define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.") #define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.") #define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures") +#define STR_REFRESH_MASTER_PASSWORD NC_("STR_REFRESH_MASTER_PASSWORD", "The master password is stored in an outdated format, you should refresh it") +#define STR_REFRESH_PASSWORD NC_("STR_REFRESH_PASSWORD", "Refresh Password") #define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane") #define STR_SFX_DOCK NC_("STR_SFX_DOCK", "Dock") diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index 6d9ef75b8ffe..b78a0c92cd3a 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -80,6 +80,7 @@ protected: DECL_LINK(GetDonateHandler, Button*, void); DECL_LINK(SwitchReadOnlyHandler, Button*, void); DECL_LINK(SignDocumentHandler, Button*, void); + DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, Button*, void); SAL_DLLPRIVATE void KillDispatcher_Impl(); virtual ~SfxViewFrame() override; diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 2d722447bdc4..8b45d32772c3 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1656,6 +1656,23 @@ #define RID_SUBSETSTR_MEDEFAIDRIN NC_("RID_SUBSETMAP", "Medefaidrin") #define RID_SUBSETSTR_OLD_SOGDIAN NC_("RID_SUBSETMAP", "Old Sogdian") #define RID_SUBSETSTR_SOGDIAN NC_("RID_SUBSETMAP", "Sogdian") +#define RID_SUBSETSTR_EGYPTIAN_HIEROGLYPH_FORMAT_CONTROLS NC_("RID_SUBSETMAP", "Egyptian Hieroglyph Format Controls") +#define RID_SUBSETSTR_ELYMAIC NC_("RID_SUBSETMAP", "Elymaic") +#define RID_SUBSETSTR_NANDINAGARI NC_("RID_SUBSETMAP", "Nandinagari") +#define RID_SUBSETSTR_NYIAKENG_PUACHUE_HMONG NC_("RID_SUBSETMAP", "Nyiakeng Puachue Hmong") +#define RID_SUBSETSTR_OTTOMAN_SIYAQ_NUMBERS NC_("RID_SUBSETMAP", "Ottoman Siyaq Numbers") +#define RID_SUBSETSTR_SMALL_KANA_EXTENSION NC_("RID_SUBSETMAP", "Small Kana Extension") +#define RID_SUBSETSTR_SYMBOLS_AND_PICTOGRAPHS_EXTENDED_A NC_("RID_SUBSETMAP", "Symbols and Pictographs Extended-A") +#define RID_SUBSETSTR_TAMIL_SUPPLEMENT NC_("RID_SUBSETMAP", "Tamil Supplement") +#define RID_SUBSETSTR_WANCHO NC_("RID_SUBSETMAP", "Wancho") +#define RID_SUBSETSTR_CHORASMIAN NC_("RID_SUBSETMAP", "Chorasmian") +#define RID_SUBSETSTR_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_G NC_("RID_SUBSETMAP", "CJK Unified Ideographs Extension G") +#define RID_SUBSETSTR_DIVES_AKURU NC_("RID_SUBSETMAP", "Dhives Akuru") +#define RID_SUBSETSTR_KHITAN_SMALL_SCRIPT NC_("RID_SUBSETMAP", "Khitan small script") +#define RID_SUBSETSTR_LISU_SUPPLEMENT NC_("RID_SUBSETMAP", "Lisu Supplement") +#define RID_SUBSETSTR_SYMBOLS_FOR_LEGACY_COMPUTING NC_("RID_SUBSETMAP", "Symbols for Legacy Computing") +#define RID_SUBSETSTR_TANGUT_SUPPLEMENT NC_("RID_SUBSETMAP", "Tangut Supplement") +#define RID_SUBSETSTR_YEZIDI NC_("RID_SUBSETMAP", "Yezidi") #define RID_SVXSTR_FRAMEDIR_LTR NC_("RID_SVXSTR_FRAMEDIR_LTR", "Left-to-right (LTR)") #define RID_SVXSTR_FRAMEDIR_RTL NC_("RID_SVXSTR_FRAMEDIR_RTL", "Right-to-left (RTL)") diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 3b91a3269478..8b42ca0cc3d7 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -197,11 +197,6 @@ public: BitmapChecksum GetChecksum() const; - SAL_DLLPRIVATE std::size_t getHash() const - { - return reinterpret_cast<std::size_t>(ImplGetImpGraphic()); - } - OUString getOriginURL() const; void setOriginURL(OUString const & rOriginURL); @@ -249,7 +244,7 @@ struct hash<Graphic> { std::size_t operator()(Graphic const & rGraphic) const { - return rGraphic.getHash(); + return static_cast<std::size_t>(rGraphic.GetChecksum()); } }; diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx index ea7615d2bdf6..159dc7afe286 100644 --- a/include/vcl/vectorgraphicdata.hxx +++ b/include/vcl/vectorgraphicdata.hxx @@ -103,6 +103,7 @@ public: const basegfx::B2DRange& getRange() const; const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const; const BitmapEx& getReplacement() const; + BitmapChecksum GetChecksum() const; }; typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 117fe2c4f581..64ddfff98873 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -687,17 +687,22 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( // all versions below 1.5.1 options.emplace_back("abort", reinterpret_cast<void*>(abort_handler)); bool hasStackSize = false; +#ifdef UNX + // Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2) + // in the class path in order to have applet support: + OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion); +#endif for (int i = 0; i < cOptions; i++) { OString opt(arOptions[i].optionString); #ifdef UNX - // Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2) - // in the class path in order to have applet support: if (opt.startsWith("-Djava.class.path=")) { - OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion); if (!sAddPath.isEmpty()) + { opt += OString(SAL_PATHSEPARATOR) + sAddPath; + sAddPath.clear(); + } } #endif if (opt == "-Xint") { @@ -742,6 +747,11 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( } #endif } +#ifdef UNX + if (!sAddPath.isEmpty()) { + options.emplace_back("-Djava.class.path=" + sAddPath, nullptr); + } +#endif std::unique_ptr<JavaVMOption[]> sarOptions(new JavaVMOption[options.size()]); for (std::vector<Option>::size_type i = 0; i != options.size(); ++i) { diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 8d870fd335ae..2caf00ed10b5 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -210,8 +210,12 @@ javaFrameworkError jfw_startVM( //In direct mode the options are specified by bootstrap variables //of the form UNO_JAVA_JFW_PARAMETER_1 .. UNO_JAVA_JFW_PARAMETER_n vmParams = jfw::BootParams::getVMParameters(); - sUserClassPath = - "-Djava.class.path=" + jfw::BootParams::getClasspath(); + auto const cp = jfw::BootParams::getClasspath(); + if (!cp.isEmpty()) + { + sUserClassPath = + "-Djava.class.path=" + cp; + } } else OSL_ASSERT(false); diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx index 206c81546974..b72fcc11dd1c 100644 --- a/jvmfwk/source/fwkbase.cxx +++ b/jvmfwk/source/fwkbase.cxx @@ -497,8 +497,10 @@ OString makeClassPathOption(OUString const & sUserClassPath) sBufCP.append(sAppCP); } - sPaths = OUStringToOString( - sBufCP.makeStringAndClear(), osl_getThreadTextEncoding()); + sPaths = OUStringToOString(sBufCP.makeStringAndClear(), osl_getThreadTextEncoding()); + if (sPaths.isEmpty()) { + return ""; + } OString sOptionClassPath("-Djava.class.path="); sOptionClassPath += sPaths; diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx index 45637de0c32c..a0d5ef65d360 100644 --- a/lotuswordpro/source/filter/lwpdrawobj.cxx +++ b/lotuswordpro/source/filter/lwpdrawobj.cxx @@ -1353,25 +1353,35 @@ void LwpDrawBitmap::Read() m_pStream->ReadUInt16( m_aBmpRec.nRotation ); // 20 == length of draw-specific fields. - // 14 == length of bmp file header. - m_aBmpRec.nFileSize = m_aObjHeader.nRecLen - 20 + 14; - m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] ); + if (m_aObjHeader.nRecLen < 20) + throw BadRead(); + + sal_uInt64 nBmpPos = m_pStream->Tell(); + sal_uInt64 nBmpLen = + std::min<sal_uInt64>(m_aObjHeader.nRecLen - 20, m_pStream->remainingSize()); BmpInfoHeader2 aInfoHeader2; m_pStream->ReadUInt32( aInfoHeader2.nHeaderLen ); + if (!m_pStream->good() || nBmpLen < aInfoHeader2.nHeaderLen) + throw BadRead(); + sal_uInt32 N; sal_uInt32 rgbTableSize; if (aInfoHeader2.nHeaderLen == sizeof(BmpInfoHeader)) { - m_pStream->ReadUInt32( aInfoHeader2.nWidth ); - m_pStream->ReadUInt32( aInfoHeader2.nHeight ); + sal_uInt16 nTmp; + + m_pStream->ReadUInt16( nTmp ); + aInfoHeader2.nWidth = nTmp; + m_pStream->ReadUInt16( nTmp ); + aInfoHeader2.nHeight = nTmp; m_pStream->ReadUInt16( aInfoHeader2.nPlanes ); m_pStream->ReadUInt16( aInfoHeader2.nBitCount ); N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount; - if (N == 24) + if (N >= 16) { rgbTableSize = 0; } @@ -1380,14 +1390,14 @@ void LwpDrawBitmap::Read() rgbTableSize = 3 * (1 << N); } } - else + else if (aInfoHeader2.nHeaderLen >= sizeof(BmpInfoHeader2)) { m_pStream->ReadUInt32( aInfoHeader2.nWidth ); m_pStream->ReadUInt32( aInfoHeader2.nHeight ); m_pStream->ReadUInt16( aInfoHeader2.nPlanes ); m_pStream->ReadUInt16( aInfoHeader2.nBitCount ); N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount; - if (N == 24) + if (N >= 16) { rgbTableSize = 0; } @@ -1395,9 +1405,15 @@ void LwpDrawBitmap::Read() { rgbTableSize = 4 * (1 << N); } - + } + else + { + throw BadRead(); } + m_aBmpRec.nFileSize = static_cast<sal_uInt32>(nBmpLen + 14); + m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] ); + sal_uInt32 nOffBits = 14 + aInfoHeader2.nHeaderLen + rgbTableSize; m_pImageData[0] = 'B'; m_pImageData[1] = 'M'; @@ -1414,50 +1430,11 @@ void LwpDrawBitmap::Read() m_pImageData[12] = static_cast<sal_uInt8>(nOffBits >> 16); m_pImageData[13] = static_cast<sal_uInt8>(nOffBits >> 24); - sal_uInt32 nDIBRemaining; sal_uInt8* pPicData = m_pImageData.get(); - if (aInfoHeader2.nHeaderLen== sizeof(BmpInfoHeader)) - { - m_pImageData[14] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen); - m_pImageData[15] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 8); - m_pImageData[16] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 16); - m_pImageData[17] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 24); - m_pImageData[18] = static_cast<sal_uInt8>(aInfoHeader2.nWidth); - m_pImageData[19] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 8); - m_pImageData[20] = static_cast<sal_uInt8>(aInfoHeader2.nHeight); - m_pImageData[21] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 8); - m_pImageData[22] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes); - m_pImageData[23] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes >> 8); - m_pImageData[24] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount); - m_pImageData[25] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount >> 8); - - nDIBRemaining = m_aBmpRec.nFileSize - 26; - pPicData += 26*sizeof(sal_uInt8); - } - else - { - m_pImageData[14] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen); - m_pImageData[15] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 8); - m_pImageData[16] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 16); - m_pImageData[17] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 24); - m_pImageData[18] = static_cast<sal_uInt8>(aInfoHeader2.nWidth); - m_pImageData[19] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 8); - m_pImageData[20] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 16); - m_pImageData[21] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 24); - m_pImageData[22] = static_cast<sal_uInt8>(aInfoHeader2.nHeight); - m_pImageData[23] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 8); - m_pImageData[24] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 16); - m_pImageData[25] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 24); - m_pImageData[26] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes); - m_pImageData[27] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes >> 8); - m_pImageData[28] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount); - m_pImageData[29] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount >> 8); - - nDIBRemaining = m_aBmpRec.nFileSize - 30; - pPicData += 30*sizeof(sal_uInt8); - } - m_pStream->ReadBytes(pPicData, nDIBRemaining); + m_pStream->Seek(nBmpPos); + if (nBmpLen != m_pStream->ReadBytes(pPicData + 14, nBmpLen)) + throw BadRead(); } OUString LwpDrawBitmap::RegisterStyle() diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 3cb8ace6ab8c..88f06de0bf63 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -27,6 +27,11 @@ <info> <desc>Contains a container for passwords.</desc> </info> + <prop oor:name="InitializationVector" oor:type="xs:string"> + <info> + <desc>Contains an initialization vector for the password encryption.</desc> + </info> + </prop> <prop oor:name="Password" oor:type="xs:string" oor:localized="false"> <info> <desc>Contains a password encoded with the master password.</desc> @@ -903,12 +908,23 @@ </info> <value>false</value> </prop> + <prop oor:name="StorageVersion" oor:type="xs:int" oor:nillable="false"> + <info> + <desc>Specifies what version of encoding scheme the password container uses.</desc> + </info> + <value>0</value> + </prop> <prop oor:name="HasMaster" oor:type="xs:boolean" oor:nillable="false"> <info> <desc>Specifies if there is a valid master password.</desc> </info> <value>false</value> </prop> + <prop oor:name="MasterInitializationVector" oor:type="xs:string"> + <info> + <desc>Contains an initialization vector for the master password encryption.</desc> + </info> + </prop> <prop oor:name="Master" oor:type="xs:string" oor:nillable="false"> <info> <desc>Contains the master password encrypted by itself.</desc> diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 20fe5e02991c..b932e371be3d 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -30,8 +30,6 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/plugin/TestPlugIn.h> -#include <o3tl/cppunittraitshelper.hxx> - #include <stringhelper.hxx> #include <valueequal.hxx> diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx index 80ce83b1d2d0..f1a151fdc836 100644 --- a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx +++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx @@ -7,9 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <sal/config.h> - -#include <o3tl/cppunittraitshelper.hxx> #include <sal/types.h> #include <cppunit/TestFixture.h> #include <cppunit/TestAssert.h> diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index c09dfe99451b..a98401351a7f 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -14,7 +14,6 @@ #include <utility> -#include <o3tl/cppunittraitshelper.hxx> #include <sal/types.h> #include <config_global.h> #include <cppunit/TestFixture.h> diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index 3c8539640522..339075decba3 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -27,7 +27,6 @@ #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> -#include <o3tl/cppunittraitshelper.hxx> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <rtl/tencinfo.h> diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index c6302eb90988..3996737053a8 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -588,14 +588,9 @@ void OP_SheetName123(LotusContext& rContext, SvStream& rStream, sal_uInt16 nLeng SCTAB nSheetNum = static_cast<SCTAB>(nDummy); rContext.pDoc->MakeTable(nSheetNum); - ::std::vector<sal_Char> sSheetName; - sSheetName.reserve(nLength-4); - for (sal_uInt16 i = 4; i < nLength; ++i) - { - sal_Char c; - rStream.ReadChar( c ); - sSheetName.push_back(c); - } + const size_t nStrLen = nLength - 4; + std::vector<sal_Char> sSheetName(nStrLen + 1); + sSheetName[rStream.ReadBytes(sSheetName.data(), nStrLen)] = 0; if (!sSheetName.empty()) { diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index b14a16bfa335..8855073d40bf 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/task/PasswordContainer.hpp> #include <officecfg/Office/Common.hxx> #include <officecfg/Setup.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -1280,6 +1281,24 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) batch->commit(); } + if (officecfg::Office::Common::Passwords::HasMaster::get() && + officecfg::Office::Common::Passwords::StorageVersion::get() == 0) + { + // master password stored in deprecated format + VclPtr<SfxInfoBarWindow> pOldMasterPasswordInfoBar = + AppendInfoBar("oldmasterpassword", + SfxResId(STR_REFRESH_MASTER_PASSWORD), InfoBarType::Danger); + if (pOldMasterPasswordInfoBar) + { + VclPtrInstance<PushButton> const xBtn(&GetWindow()); + xBtn->SetText(SfxResId(STR_REFRESH_PASSWORD)); + xBtn->SetSizePixel(xBtn->GetOptimalSize()); + xBtn->SetClickHdl(LINK(this, + SfxViewFrame, RefreshMasterPasswordHdl)); + pOldMasterPasswordInfoBar->addButton(xBtn); + } + } + // read-only infobar if necessary const SfxViewShell *pVSh; const SfxShell *pFSh; @@ -1436,6 +1455,27 @@ IMPL_LINK_NOARG(SfxViewFrame, SignDocumentHandler, Button*, void) GetDispatcher()->Execute(SID_SIGNATURE); } +IMPL_LINK_NOARG(SfxViewFrame, RefreshMasterPasswordHdl, Button*, void) +{ + bool bChanged = false; + try + { + Reference< task::XPasswordContainer2 > xMasterPasswd( + task::PasswordContainer::create(comphelper::getProcessComponentContext())); + + css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface(); + css::uno::Reference<css::awt::XWindow> xContainerWindow = xFrame->getContainerWindow(); + + uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), + xContainerWindow)); + bChanged = xMasterPasswd->changeMasterPassword(xTmpHandler); + } + catch (const Exception&) + {} + if (bChanged) + RemoveInfoBar(u"oldmasterpassword"); +} + void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) { m_pImpl->bResizeInToOut = true; diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index cc035c45a2d9..332f037a4fe5 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -412,8 +412,12 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa if (!(checkExtension(ext, env) && checkExtension( ext, - ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.CLASS;" - ".JAR;.APPLICATION;.LNK;.SCR"))) + ".ADE;.ADP;.APK;.APPLICATION;.APPX;.APPXBUNDLE;.BAT;.CAB;.CHM;.CLASS;" + ".CMD;.COM;.CPL;.DLL;.DMG;.EX;.EX_;.EXE;.GADGET;.HTA;.INF;.INS;.IPA;" + ".ISO;.ISP;.JAR;.JS;.JSE;.LIB;.LNK;.MDE;.MSC;.MSH;.MSH1;.MSH2;.MSHXML;" + ".MSH1XML;.MSH2XML;.MSI;.MSIX;.MSIXBUNDLE;.MSP;.MST;.NSH;.PIF;.PS1;" + ".PS1XML;.PS2;.PS2XML;.PSC1;.PSC2;.PY;.REG;.SCF;.SCR;.SCT;.SHB;.SYS;" + ".VB;.VBE;.VBS;.VXD;.WS;.WSC;.WSF;.WSH;"))) { throw css::lang::IllegalArgumentException( "XSystemShellExecute.execute, cannot process <" + aCommand + ">", {}, diff --git a/solenv/flatpak-manifest.in b/solenv/flatpak-manifest.in index a211b4e3291f..600d780da8d7 100644 --- a/solenv/flatpak-manifest.in +++ b/solenv/flatpak-manifest.in @@ -54,10 +54,11 @@ "type": "shell" }, { - "url": "https://dev-www.libreoffice.org/src/pdfium-4306.tar.bz2", - "sha256": "eca406d47ac7e2a84dcc86f93c08f96e591d409589e881477fa75e488e4851d8", + "url": "https://dev-www.libreoffice.org/src/pdfium-4643.tar.bz2", + "sha256": "eb98a77eaaab9e9e8de541cfd18b9438dd3c538bd5ef163820353179727f5dc9", "type": "file", - "dest-filename": "external/tarballs/pdfium-4306.tar.bz2" + "dest": "external/tarballs", + "dest-filename": "pdfium-4643.tar.bz2" }, { "url": "https://dev-www.libreoffice.org/src/0168229624cfac409e766913506961a8-ucpp-1.3.2.tar.gz", diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index 057ef8fd5762..c5e335071fa3 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -59,7 +59,7 @@ gb_CFLAGS_COMMON := \ -Wstrict-prototypes \ -Wundef \ -Wunreachable-code \ - $(if $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),,-Wunused-macros) \ + $(if $(or $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),$(findstring sccache,$(CC))),,-Wunused-macros) \ -finput-charset=UTF-8 \ -fmessage-length=0 \ -fno-common \ @@ -73,7 +73,7 @@ gb_CXXFLAGS_COMMON := \ -Wextra \ -Wundef \ -Wunreachable-code \ - $(if $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),,-Wunused-macros) \ + $(if $(or $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CXX)),$(findstring icecc,$(CCACHE_PREFIX)))),$(findstring sccache,$(CXX))),,-Wunused-macros) \ -finput-charset=UTF-8 \ -fmessage-length=0 \ -fno-common \ diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk index 1fefa80fef61..a86e2a37ccf0 100644 --- a/solenv/gbuild/platform/com_MSC_class.mk +++ b/solenv/gbuild/platform/com_MSC_class.mk @@ -378,11 +378,7 @@ endef gb_CppunitTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-WNT.sh gb_CppunitTest_PYTHONDEPS := $(call gb_Package_get_target,python3) gb_CppunitTest_DEFS := -D_DLL -ifeq ($(GNUMAKE_WIN_NATIVE),TRUE) -gb_CppunitTest_CPPTESTPRECOMMAND := $(call gb_Helper_prepend_ld_path,$(shell cygpath -w $(gb_Library_DLLDIR));$(shell cygpath -w $(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll,ReleaseDll))) -else gb_CppunitTest_CPPTESTPRECOMMAND := $(call gb_Helper_prepend_ld_path,$(shell cygpath -u $(gb_Library_DLLDIR)):$(shell cygpath -u $(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll,ReleaseDll))) -endif gb_CppunitTest_get_filename = test_$(1).dll gb_CppunitTest_get_ilibfilename = itest_$(1).lib diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk index e6afe0b5ad2a..4118a666ceea 100644 --- a/solenv/gbuild/platform/com_MSC_defs.mk +++ b/solenv/gbuild/platform/com_MSC_defs.mk @@ -51,6 +51,7 @@ gb_COMPILERDEFS := \ -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING \ -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING \ -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING \ + -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING \ -D_CRT_NON_CONFORMING_SWPRINTFS \ -D_CRT_NONSTDC_NO_DEPRECATE \ -D_CRT_SECURE_NO_DEPRECATE \ @@ -167,6 +168,7 @@ endif gb_CXXFLAGS := \ -utf-8 \ $(CXXFLAGS_CXX11) \ + $(if $(filter-out 140,$(VCVER)),-std:c++17) \ -Gd \ -GR \ -Gs \ @@ -336,20 +338,6 @@ gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := endif # Helper class - -ifeq ($(GNUMAKE_WIN_NATIVE),TRUE) -gb_Helper_set_ld_path := PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$$PATH" - -define gb_Helper_prepend_ld_path -PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$(1);$$PATH" -endef - -# $(1): one directory pathname to append to the ld path -define gb_Helper_extend_ld_path -$(gb_Helper_set_ld_path)';$(shell cygpath -w $(1))' -endef - -else gb_Helper_set_ld_path := PATH="$(shell cygpath -u $(INSTDIR)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR)/$(LIBO_BIN_FOLDER)):$$PATH" define gb_Helper_prepend_ld_path @@ -361,6 +349,4 @@ define gb_Helper_extend_ld_path $(gb_Helper_set_ld_path):$(shell cygpath -u $(1)) endef -endif - # vim: set noet sw=4: diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index 19cb5167cc2f..cb24bbdff78b 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -10,7 +10,6 @@ #include <sal/config.h> #include <test/bootstrapfixture.hxx> -#include <o3tl/cppunittraitshelper.hxx> #include <sfx2/sfxmodelfactory.hxx> #include <document.hxx> diff --git a/starmath/qa/extras/mmlexport-test.cxx b/starmath/qa/extras/mmlexport-test.cxx index cbcc1d040c26..8fdaa566a778 100644 --- a/starmath/qa/extras/mmlexport-test.cxx +++ b/starmath/qa/extras/mmlexport-test.cxx @@ -8,8 +8,6 @@ */ #include <sal/config.h> - -#include <o3tl/cppunittraitshelper.hxx> #include <test/bootstrapfixture.hxx> #include <test/xmltesttools.hxx> #include <unotools/tempfile.hxx> diff --git a/svl/qa/unit/test_INetContentType.cxx b/svl/qa/unit/test_INetContentType.cxx index 8495d2d93273..2d060d271b51 100644 --- a/svl/qa/unit/test_INetContentType.cxx +++ b/svl/qa/unit/test_INetContentType.cxx @@ -40,8 +40,8 @@ public: void Test::testBad() { OUString in("foo=bar"); CPPUNIT_ASSERT_EQUAL( - static_cast<sal_Unicode const *>(nullptr), - INetMIME::scanContentType(in)); + static_cast<void const *>(nullptr), + static_cast<void const *>(INetMIME::scanContentType(in))); OUString t; OUString s; INetContentTypeParameterList ps; @@ -54,8 +54,8 @@ void Test::testBad() { void Test::testFull() { OUString in("foo/bar;baz=boz"); CPPUNIT_ASSERT_EQUAL( - in.getStr() + in.getLength(), - INetMIME::scanContentType(in)); + static_cast<void const *>(in.getStr() + in.getLength()), + static_cast<void const *>(INetMIME::scanContentType(in))); OUString t; OUString s; INetContentTypeParameterList ps; @@ -70,8 +70,8 @@ void Test::testFull() { void Test::testFollow() { OUString in("foo/bar;baz=boz;base64,"); CPPUNIT_ASSERT_EQUAL( - in.getStr() + std::strlen("foo/bar;baz=boz"), - INetMIME::scanContentType(in)); + static_cast<void const *>(in.getStr() + std::strlen("foo/bar;baz=boz")), + static_cast<void const *>(INetMIME::scanContentType(in))); OUString t; OUString s; INetContentTypeParameterList ps; diff --git a/svl/qa/unit/test_lngmisc.cxx b/svl/qa/unit/test_lngmisc.cxx index e8daf852ddf2..b4ba30c6c63b 100644 --- a/svl/qa/unit/test_lngmisc.cxx +++ b/svl/qa/unit/test_lngmisc.cxx @@ -7,9 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <sal/config.h> - -#include <o3tl/cppunittraitshelper.hxx> #include <sal/types.h> #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index eb52bc98e520..9b4b3088e5cf 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> +#include <sal/log.hxx> #include "passwordcontainer.hxx" @@ -183,23 +185,24 @@ PassMap StorageItem::getInfo() Sequence< OUString > aNodeNames = ConfigItem::GetNodeNames( "Store" ); sal_Int32 aNodeCount = aNodeNames.getLength(); - Sequence< OUString > aPropNames( aNodeCount ); - sal_Int32 aNodeInd; + Sequence< OUString > aPropNames( aNodeCount * 2); - for( aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd ) - { - aPropNames[aNodeInd] = "Store/Passwordstorage['" + aNodeNames[aNodeInd] + "']/Password"; - } + std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.begin(), + [](const OUString& rName) -> OUString { + return "Store/Passwordstorage['" + rName + "']/Password"; }); + std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.getArray() + aNodeCount, + [](const OUString& rName) -> OUString { + return "Store/Passwordstorage['" + rName + "']/InitializationVector"; }); Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aPropNames ); - if( aPropertyValues.getLength() != aNodeNames.getLength() ) + if( aPropertyValues.getLength() != aNodeCount * 2) { - OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" ); + OSL_FAIL( "Problems during reading" ); return aResult; } - for( aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd ) + for( sal_Int32 aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd ) { std::vector< OUString > aUrlUsr = getInfoFromInd( aNodeNames[aNodeInd] ); @@ -209,14 +212,16 @@ PassMap StorageItem::getInfo() OUString aName = aUrlUsr[1]; OUString aEPasswd; + OUString aIV; aPropertyValues[aNodeInd] >>= aEPasswd; + aPropertyValues[aNodeInd + aNodeCount] >>= aIV; PassMap::iterator aIter = aResult.find( aUrl ); if( aIter != aResult.end() ) - aIter->second.emplace_back( aName, aEPasswd ); + aIter->second.emplace_back( aName, aEPasswd, aIV ); else { - NamePassRecord aNewRecord( aName, aEPasswd ); + NamePassRecord aNewRecord( aName, aEPasswd, aIV ); std::vector< NamePassRecord > listToAdd( 1, aNewRecord ); aResult.insert( PairUrlRecord( aUrl, listToAdd ) ); @@ -252,7 +257,7 @@ bool StorageItem::useStorage() if( aPropertyValues.getLength() != aNodeNames.getLength() ) { - OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" ); + OSL_FAIL( "Problems during reading" ); return false; } @@ -262,53 +267,79 @@ bool StorageItem::useStorage() return aResult; } +sal_Int32 StorageItem::getStorageVersion() +{ + Sequence<OUString> aNodeNames { "StorageVersion" }; + + Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aNodeNames ); + + if( aPropertyValues.getLength() != aNodeNames.getLength() ) + { + OSL_FAIL( "Problems during reading" ); + return 0; + } + + sal_Int32 nResult = 0; + aPropertyValues[0] >>= nResult; -bool StorageItem::getEncodedMP( OUString& aResult ) + return nResult; +} + +bool StorageItem::getEncodedMP( OUString& aResult, OUString& aResultIV ) { if( hasEncoded ) { aResult = mEncoded; + aResultIV = mEncodedIV; return true; } - Sequence< OUString > aNodeNames( 2 ); + Sequence< OUString > aNodeNames( 3 ); aNodeNames[0] = "HasMaster"; aNodeNames[1] = "Master"; + aNodeNames[2] = "MasterInitializationVector"; Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aNodeNames ); if( aPropertyValues.getLength() != aNodeNames.getLength() ) { - OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" ); + OSL_FAIL( "Problems during reading" ); return false; } aPropertyValues[0] >>= hasEncoded; aPropertyValues[1] >>= mEncoded; + aPropertyValues[2] >>= mEncodedIV; aResult = mEncoded; + aResultIV = mEncodedIV; return hasEncoded; } -void StorageItem::setEncodedMP( const OUString& aEncoded, bool bAcceptEmpty ) +void StorageItem::setEncodedMP( const OUString& aEncoded, const OUString& aEncodedIV, bool bAcceptEmpty ) { - Sequence< OUString > sendNames(2); - Sequence< uno::Any > sendVals(2); + Sequence< OUString > sendNames(4); + Sequence< uno::Any > sendVals(4); sendNames[0] = "HasMaster"; sendNames[1] = "Master"; + sendNames[2] = "MasterInitializationVector"; + sendNames[3] = "StorageVersion"; bool bHasMaster = ( !aEncoded.isEmpty() || bAcceptEmpty ); sendVals[0] <<= bHasMaster; sendVals[1] <<= aEncoded; + sendVals[2] <<= aEncodedIV; + sendVals[3] <<= nCurrentStorageVersion; ConfigItem::SetModified(); ConfigItem::PutProperties( sendNames, sendVals ); hasEncoded = bHasMaster; mEncoded = aEncoded; + mEncodedIV = aEncodedIV; } @@ -344,11 +375,13 @@ void StorageItem::update( const OUString& aURL, const NamePassRecord& aRecord ) forIndex.push_back( aURL ); forIndex.push_back( aRecord.GetUserName() ); - Sequence< beans::PropertyValue > sendSeq(1); + Sequence< beans::PropertyValue > sendSeq(2); - sendSeq[0].Name = "Store/Passwordstorage['" + createIndex( forIndex ) + "']/Password"; + sendSeq[0].Name = "Store/Passwordstorage['" + createIndex( { aURL, aRecord.GetUserName() } ) + "']/InitializationVector"; + sendSeq[0].Value <<= aRecord.GetPersistentIV(); - sendSeq[0].Value <<= aRecord.GetPersPasswords(); + sendSeq[1].Name = "Store/Passwordstorage['" + createIndex( forIndex ) + "']/Password"; + sendSeq[1].Value <<= aRecord.GetPersPasswords(); ConfigItem::SetModified(); ConfigItem::SetSetProperties( "Store", sendSeq ); @@ -409,7 +442,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& ) } } -std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode ) +std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode ) { if( !aMasterPasswd.isEmpty() ) { @@ -424,9 +457,16 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16)); + unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0}; + if (!aIV.isEmpty()) + { + for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) + iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16)); + } + rtlCipherError result = rtl_cipher_init ( aDecoder, rtl_Cipher_DirectionDecode, - code, RTL_DIGEST_LENGTH_MD5, nullptr, 0 ); + code, RTL_DIGEST_LENGTH_MD5, iv, RTL_DIGEST_LENGTH_MD5 ); if( result == rtl_Cipher_E_None ) { @@ -459,7 +499,7 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin "Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode); } -OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPasswd ) +OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPasswd) { if( !aMasterPasswd.isEmpty() ) { @@ -476,9 +516,16 @@ OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16)); + unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0}; + if (!aIV.isEmpty()) + { + for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) + iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16)); + } + rtlCipherError result = rtl_cipher_init ( aEncoder, rtl_Cipher_DirectionEncode, - code, RTL_DIGEST_LENGTH_MD5, nullptr, 0 ); + code, RTL_DIGEST_LENGTH_MD5, iv, RTL_DIGEST_LENGTH_MD5 ); if( result == rtl_Cipher_E_None ) { @@ -546,7 +593,7 @@ void PasswordContainer::UpdateVector( const OUString& aURL, std::vector< NamePas if( aRecord.HasPasswords( PERSISTENT_RECORD ) ) { - aNPIter.SetPersPasswords( aRecord.GetPersPasswords() ); + aNPIter.SetPersPasswords( aRecord.GetPersPasswords(), aRecord.GetPersistentIV() ); if( writeFile ) { @@ -579,7 +626,8 @@ UserRecord PasswordContainer::CopyToUserRecord( const NamePassRecord& aRecord, b { try { - ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ); + ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), aRecord.GetPersistentIV(), + GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ); aPasswords.insert( aPasswords.end(), aDecodedPasswords.begin(), aDecodedPasswords.end() ); } catch( NoMasterException& ) @@ -624,6 +672,19 @@ void SAL_CALL PasswordContainer::addPersistent( const OUString& Url, const OUStr PrivateAdd( Url, UserName, Passwords, PERSISTENT_RECORD, aHandler ); } +OUString PasswordContainer::createIV() +{ + rtlRandomPool randomPool = mRandomPool.get(); + unsigned char iv[RTL_DIGEST_LENGTH_MD5]; + rtl_random_getBytes(randomPool, iv, RTL_DIGEST_LENGTH_MD5); + OUStringBuffer aBuffer; + for (sal_uInt8 i : iv) + { + aBuffer.append(OUString::number(i >> 4, 16)); + aBuffer.append(OUString::number(i & 15, 16)); + } + return aBuffer.makeStringAndClear(); +} void PasswordContainer::PrivateAdd( const OUString& Url, const OUString& UserName, const Sequence< OUString >& Passwords, char Mode, const Reference< XInteractionHandler >& aHandler ) { @@ -631,7 +692,11 @@ void PasswordContainer::PrivateAdd( const OUString& Url, const OUString& UserNam ::std::vector< OUString > aStorePass = comphelper::sequenceToContainer< std::vector<OUString> >( Passwords ); if( Mode == PERSISTENT_RECORD ) - aRecord.SetPersPasswords( EncodePasswords( aStorePass, GetMasterPassword( aHandler ) ) ); + { + OUString sIV = createIV(); + OUString sEncodedPasswords = EncodePasswords( aStorePass, sIV, GetMasterPassword( aHandler ) ); + aRecord.SetPersPasswords( sEncodedPasswords, sIV ); + } else if( Mode == MEMORY_RECORD ) aRecord.SetMemPasswords( aStorePass ); else @@ -803,6 +868,18 @@ OUString PasswordContainer::RequestPasswordFromUser( PasswordRequestMode aRMode, return aResult; } +// Mangle the key to match an old bug +static OUString ReencodeAsOldHash(const OUString& rPass) +{ + OUStringBuffer aBuffer; + for (int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ++ind) + { + unsigned char i = static_cast<char>(rPass.copy(ind * 2, 2).toUInt32(16)); + aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4))); + aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15))); + } + return aBuffer.makeStringAndClear(); +} OUString const & PasswordContainer::GetMasterPassword( const Reference< XInteractionHandler >& aHandler ) { @@ -812,10 +889,10 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac if( m_aMasterPasswd.isEmpty() && aHandler.is() ) { - OUString aEncodedMP; + OUString aEncodedMP, aEncodedMPIV; bool bDefaultPassword = false; - if( !m_pStorageFile->getEncodedMP( aEncodedMP ) ) + if( !m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) aRMode = PasswordRequestMode_PASSWORD_CREATE; else if ( aEncodedMP.isEmpty() ) { @@ -837,11 +914,15 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac m_aMasterPasswd = aPass; std::vector< OUString > aMaster( 1, m_aMasterPasswd ); - m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, m_aMasterPasswd ) ); + OUString sIV = createIV(); + m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, sIV, m_aMasterPasswd ), sIV ); } else { - std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass, aRMode ) ); + if (m_pStorageFile->getStorageVersion() == 0) + aPass = ReencodeAsOldHash(aPass); + + std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aEncodedMPIV, aPass, aRMode ) ); if( aRM.empty() || aPass != aRM[0] ) { bAskAgain = true; @@ -998,7 +1079,8 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere { sal_Int32 oldLen = aUsers.getLength(); aUsers.realloc( oldLen + 1 ); - aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) ); + aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), aNP.GetPersistentIV(), + GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) ); } if( aUsers.getLength() ) @@ -1015,12 +1097,12 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere sal_Bool SAL_CALL PasswordContainer::authorizateWithMasterPassword( const uno::Reference< task::XInteractionHandler >& xHandler ) { bool bResult = false; - OUString aEncodedMP; + OUString aEncodedMP, aEncodedMPIV; uno::Reference< task::XInteractionHandler > xTmpHandler = xHandler; ::osl::MutexGuard aGuard( mMutex ); // the method should fail if there is no master password - if( m_pStorageFile && m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) ) + if( m_pStorageFile && m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) { if ( aEncodedMP.isEmpty() ) { @@ -1045,6 +1127,13 @@ sal_Bool SAL_CALL PasswordContainer::authorizateWithMasterPassword( const uno::R do { aPass = RequestPasswordFromUser( aRMode, xTmpHandler ); + + + if (!aPass.isEmpty() && m_pStorageFile->getStorageVersion() == 0) + { + aPass = ReencodeAsOldHash(aPass); + } + bResult = ( !aPass.isEmpty() && aPass == m_aMasterPasswd ); aRMode = PasswordRequestMode_PASSWORD_REENTER; // further questions with error notification } while( !bResult && !aPass.isEmpty() ); @@ -1082,8 +1171,8 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference< bool bCanChangePassword = true; // if there is already a stored master password it should be entered by the user before the change happen - OUString aEncodedMP; - if( !m_aMasterPasswd.isEmpty() || m_pStorageFile->getEncodedMP( aEncodedMP ) ) + OUString aEncodedMP, aEncodedMPIV; + if( !m_aMasterPasswd.isEmpty() || m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) bCanChangePassword = authorizateWithMasterPassword( xTmpHandler ); if ( bCanChangePassword ) @@ -1102,14 +1191,13 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference< // store the new master password m_aMasterPasswd = aPass; std::vector< OUString > aMaster( 1, m_aMasterPasswd ); - m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, m_aMasterPasswd ) ); + OUString aIV = createIV(); + m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, aIV, m_aMasterPasswd ), aIV ); // store all the entries with the new password - for ( int nURLInd = 0; nURLInd < aPersistent.getLength(); nURLInd++ ) - for ( int nNameInd = 0; nNameInd< aPersistent[nURLInd].UserList.getLength(); nNameInd++ ) - addPersistent( aPersistent[nURLInd].Url, - aPersistent[nURLInd].UserList[nNameInd].UserName, - aPersistent[nURLInd].UserList[nNameInd].Passwords, + for ( const auto& rURL : aPersistent ) + for ( const auto& rUser : rURL.UserList ) + addPersistent( rURL.Url, rUser.UserName, rUser.Passwords, uno::Reference< task::XInteractionHandler >() ); bResult = true; @@ -1129,7 +1217,7 @@ void SAL_CALL PasswordContainer::removeMasterPassword() if ( m_pStorageFile ) { m_aMasterPasswd.clear(); - m_pStorageFile->setEncodedMP( OUString() ); // let the master password be removed from configuration + m_pStorageFile->setEncodedMP( OUString(), OUString() ); // let the master password be removed from configuration } } @@ -1140,8 +1228,8 @@ sal_Bool SAL_CALL PasswordContainer::hasMasterPassword( ) if ( !m_pStorageFile ) throw uno::RuntimeException(); - OUString aEncodedMP; - return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) ); + OUString aEncodedMP, aEncodedMPIV; + return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ); } sal_Bool SAL_CALL PasswordContainer::allowPersistentStoring( sal_Bool bAllow ) @@ -1188,8 +1276,8 @@ sal_Bool SAL_CALL PasswordContainer::useDefaultMasterPassword( const uno::Refere bool bCanChangePassword = true; // if there is already a stored nondefault master password it should be entered by the user before the change happen - OUString aEncodedMP; - if( m_pStorageFile->getEncodedMP( aEncodedMP ) && !aEncodedMP.isEmpty() ) + OUString aEncodedMP, aEncodedMPIV; + if( m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) && !aEncodedMP.isEmpty() ) bCanChangePassword = authorizateWithMasterPassword( xTmpHandler ); if ( bCanChangePassword ) @@ -1206,14 +1294,12 @@ sal_Bool SAL_CALL PasswordContainer::useDefaultMasterPassword( const uno::Refere // store the empty string to flag the default master password m_aMasterPasswd = aPass; - m_pStorageFile->setEncodedMP( OUString(), true ); + m_pStorageFile->setEncodedMP( OUString(), OUString(), true ); // store all the entries with the new password - for ( int nURLInd = 0; nURLInd < aPersistent.getLength(); nURLInd++ ) - for ( int nNameInd = 0; nNameInd< aPersistent[nURLInd].UserList.getLength(); nNameInd++ ) - addPersistent( aPersistent[nURLInd].Url, - aPersistent[nURLInd].UserList[nNameInd].UserName, - aPersistent[nURLInd].UserList[nNameInd].Passwords, + for ( const auto& rURL : aPersistent ) + for ( const auto& rUser : rURL.UserList ) + addPersistent( rURL.Url, rUser.UserName, rUser.Passwords, uno::Reference< task::XInteractionHandler >() ); bResult = true; @@ -1232,8 +1318,8 @@ sal_Bool SAL_CALL PasswordContainer::isDefaultMasterPasswordUsed() if ( !m_pStorageFile ) throw uno::RuntimeException(); - OUString aEncodedMP; - return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) && aEncodedMP.isEmpty() ); + OUString aEncodedMP, aEncodedMPIV; + return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) && aEncodedMP.isEmpty() ); } diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx index ad62ac0c91bd..94ca40dcf90b 100644 --- a/svl/source/passwordcontainer/passwordcontainer.hxx +++ b/svl/source/passwordcontainer/passwordcontainer.hxx @@ -36,6 +36,7 @@ #include <unotools/configitem.hxx> #include <ucbhelper/interactionrequest.hxx> +#include <rtl/random.h> #include <rtl/ref.hxx> #include <osl/mutex.hxx> @@ -54,11 +55,12 @@ class NamePassRecord ::std::vector< OUString > m_aMemPass; // persistent passwords are encrypted in one string - bool m_bHasPersPass; + bool m_bHasPersPass; OUString m_aPersPass; + OUString m_aPersistentIV; void InitArrays( bool bHasMemoryList, const ::std::vector< OUString >& aMemoryList, - bool bHasPersistentList, const OUString& aPersistentList ) + bool bHasPersistentList, const OUString& aPersistentList, const OUString& aPersistentIV ) { m_bHasMemPass = bHasMemoryList; if ( bHasMemoryList ) @@ -66,7 +68,10 @@ class NamePassRecord m_bHasPersPass = bHasPersistentList; if ( bHasPersistentList ) + { m_aPersPass = aPersistentList; + m_aPersistentIV = aPersistentIV; + } } public: @@ -78,11 +83,12 @@ public: { } - NamePassRecord( const OUString& aName, const OUString& aPersistentList ) + NamePassRecord( const OUString& aName, const OUString& aPersistentList, const OUString& aPersistentIV ) : m_aName( aName ) , m_bHasMemPass( false ) , m_bHasPersPass( true ) , m_aPersPass( aPersistentList ) + , m_aPersistentIV( aPersistentIV ) { } @@ -91,7 +97,8 @@ public: , m_bHasMemPass( false ) , m_bHasPersPass( false ) { - InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass ); + InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, + aRecord.m_bHasPersPass, aRecord.m_aPersPass, aRecord.m_aPersistentIV ); } NamePassRecord& operator=( const NamePassRecord& aRecord ) @@ -102,7 +109,9 @@ public: m_aMemPass.clear(); m_aPersPass.clear(); - InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass ); + m_aPersistentIV.clear(); + InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, + aRecord.m_bHasPersPass, aRecord.m_aPersPass, aRecord.m_aPersistentIV ); } return *this; } @@ -138,15 +147,24 @@ public: return OUString(); } + OUString GetPersistentIV() const + { + if ( m_bHasPersPass ) + return m_aPersistentIV; + + return OUString(); + } + void SetMemPasswords( const ::std::vector< OUString >& aMemList ) { m_aMemPass = aMemList; m_bHasMemPass = true; } - void SetPersPasswords( const OUString& aPersList ) + void SetPersPasswords( const OUString& aPersList, const OUString& aPersIV ) { m_aPersPass = aPersList; + m_aPersistentIV = aPersIV; m_bHasPersPass = true; } @@ -161,6 +179,7 @@ public: { m_bHasPersPass = false; m_aPersPass.clear(); + m_aPersistentIV.clear(); } } @@ -170,6 +189,10 @@ public: typedef ::std::pair< const OUString, ::std::vector< NamePassRecord > > PairUrlRecord; typedef ::std::map< OUString, ::std::vector< NamePassRecord > > PassMap; +// org.openoffice.Office.Common/Passwords/StorageVersion bump if details of +// how password details are saved changes. Enables migration from previous +// schemes. +constexpr sal_Int32 nCurrentStorageVersion = 1; class PasswordContainer; @@ -180,6 +203,7 @@ private: PasswordContainer* mainCont; bool hasEncoded; OUString mEncoded; + OUString mEncodedIV; virtual void ImplCommit() override; @@ -198,8 +222,10 @@ public: void remove( const OUString& url, const OUString& rec ); void clear(); - bool getEncodedMP( OUString& aResult ); - void setEncodedMP( const OUString& aResult, bool bAcceptEnmpty = false ); + sal_Int32 getStorageVersion(); + + bool getEncodedMP( OUString& aResult, OUString& aResultIV ); + void setEncodedMP( const OUString& aResult, const OUString& aResultIV, bool bAcceptEmpty = false ); void setUseStorage( bool bUse ); bool useStorage(); @@ -220,6 +246,29 @@ private: css::uno::Reference< css::lang::XComponent > mComponent; SysCredentialsConfig mUrlContainer; + class RandomPool + { + private: + rtlRandomPool m_aRandomPool; + public: + RandomPool() : m_aRandomPool(rtl_random_createPool()) + { + } + rtlRandomPool get() + { + return m_aRandomPool; + } + ~RandomPool() + { + // Clean up random pool memory + rtl_random_destroyPool(m_aRandomPool); + } + }; + + RandomPool mRandomPool; + + OUString createIV(); + /// @throws css::uno::RuntimeException css::uno::Sequence< css::task::UserRecord > CopyToUserRecordSequence( const ::std::vector< NamePassRecord >& original, @@ -270,10 +319,10 @@ css::task::UrlRecord find( const css::uno::Reference< css::task::XInteractionHandler >& Handler ); /// @throws css::uno::RuntimeException - static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword, css::task::PasswordRequestMode mode ); + static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode ); /// @throws css::uno::RuntimeException - static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPassword ); + static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPassword ); public: PasswordContainer( const css::uno::Reference< css::lang::XMultiServiceFactory >& ); diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index 81ecf1f30320..2513b35e898d 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -1779,6 +1779,61 @@ void SubsetMap::InitList() aAllSubsets.emplace_back( 0x10F30, 0x10F6F, SvxResId(RID_SUBSETSTR_SOGDIAN) ); break; #endif +#if (U_ICU_VERSION_MAJOR_NUM >= 64) + case UBLOCK_EGYPTIAN_HIEROGLYPH_FORMAT_CONTROLS: + aAllSubsets.emplace_back( 0x13430, 0x1343F, SvxResId(RID_SUBSETSTR_EGYPTIAN_HIEROGLYPH_FORMAT_CONTROLS) ); + break; + case UBLOCK_ELYMAIC: + aAllSubsets.emplace_back( 0x10FE0, 0x10FFF, SvxResId(RID_SUBSETSTR_ELYMAIC) ); + break; + case UBLOCK_NANDINAGARI: + aAllSubsets.emplace_back( 0x119A0, 0x119FF, SvxResId(RID_SUBSETSTR_NANDINAGARI) ); + break; + case UBLOCK_NYIAKENG_PUACHUE_HMONG: + aAllSubsets.emplace_back( 0x1E100, 0x1E14F, SvxResId(RID_SUBSETSTR_NYIAKENG_PUACHUE_HMONG) ); + break; + case UBLOCK_OTTOMAN_SIYAQ_NUMBERS: + aAllSubsets.emplace_back( 0x1ED00, 0x1ED4F, SvxResId(RID_SUBSETSTR_OTTOMAN_SIYAQ_NUMBERS) ); + break; + case UBLOCK_SMALL_KANA_EXTENSION: + aAllSubsets.emplace_back( 0x1B130, 0x1B16F, SvxResId(RID_SUBSETSTR_SMALL_KANA_EXTENSION) ); + break; + case UBLOCK_SYMBOLS_AND_PICTOGRAPHS_EXTENDED_A: + aAllSubsets.emplace_back( 0x1FA70, 0x1FAFF, SvxResId(RID_SUBSETSTR_SYMBOLS_AND_PICTOGRAPHS_EXTENDED_A) ); + break; + case UBLOCK_TAMIL_SUPPLEMENT: + aAllSubsets.emplace_back( 0x11FC0, 0x11FFF, SvxResId(RID_SUBSETSTR_TAMIL_SUPPLEMENT) ); + break; + case UBLOCK_WANCHO: + aAllSubsets.emplace_back( 0x1E2C0, 0x1E2FF, SvxResId(RID_SUBSETSTR_WANCHO) ); + break; +#endif +#if (U_ICU_VERSION_MAJOR_NUM >= 66) + case UBLOCK_CHORASMIAN: + aAllSubsets.emplace_back( 0x10FB0, 0x10FDF, SvxResId(RID_SUBSETSTR_CHORASMIAN) ); + break; + case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_G: + aAllSubsets.emplace_back( 0x30000, 0x3134F, SvxResId(RID_SUBSETSTR_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_G) ); + break; + case UBLOCK_DIVES_AKURU: + aAllSubsets.emplace_back( 0x11900, 0x1195F, SvxResId(RID_SUBSETSTR_DIVES_AKURU) ); + break; + case UBLOCK_KHITAN_SMALL_SCRIPT: + aAllSubsets.emplace_back( 0x18B00, 0x18CFF, SvxResId(RID_SUBSETSTR_KHITAN_SMALL_SCRIPT) ); + break; + case UBLOCK_LISU_SUPPLEMENT: + aAllSubsets.emplace_back( 0x11FB0, 0x11FBF, SvxResId(RID_SUBSETSTR_LISU_SUPPLEMENT) ); + break; + case UBLOCK_SYMBOLS_FOR_LEGACY_COMPUTING: + aAllSubsets.emplace_back( 0x1FB00, 0x1FBFF, SvxResId(RID_SUBSETSTR_SYMBOLS_FOR_LEGACY_COMPUTING) ); + break; + case UBLOCK_TANGUT_SUPPLEMENT: + aAllSubsets.emplace_back( 0x18D00, 0x18D8F, SvxResId(RID_SUBSETSTR_TANGUT_SUPPLEMENT) ); + break; + case UBLOCK_YEZIDI: + aAllSubsets.emplace_back( 0x10E80, 0x10EBF, SvxResId(RID_SUBSETSTR_YEZIDI) ); + break; +#endif } diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 3d46fcdd55fc..529a104999f0 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -768,7 +768,7 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex const Matrix aOldMatrix = mCurMatrix; FS_MATRIX matrix; - FPDFFormObj_GetMatrix(pPageObject, &matrix); + FPDFPageObj_GetMatrix(pPageObject, &matrix); mCurMatrix = Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); const int nCount = FPDFFormObj_CountObjects(pPageObject); @@ -798,7 +798,7 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex return; FS_MATRIX matrix; - FPDFTextObj_GetMatrix(pPageObject, &matrix); + FPDFPageObj_GetMatrix(pPageObject, &matrix); Matrix aTextMatrix(mCurMatrix); aTextMatrix.Transform(left, right, top, bottom); @@ -807,7 +807,8 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex const int nChars = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0); std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars]); - const int nActualChars = FPDFTextObj_GetText(pPageObject, pTextPage, pText.get(), nChars); + const int nActualChars = FPDFTextObj_GetText( + pPageObject, pTextPage, reinterpret_cast<FPDF_WCHAR*>(pText.get()), nChars); if (nActualChars <= 0) { return; @@ -815,7 +816,8 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex OUString sText(pText.get(), nActualChars); - const double dFontSize = FPDFTextObj_GetFontSize(pPageObject); + float dFontSize{}; + FPDFTextObj_GetFontSize(pPageObject, &dFontSize); double dFontSizeH = fabs(sqrt2(matrix.a, matrix.c) * dFontSize); double dFontSizeV = fabs(sqrt2(matrix.b, matrix.d) * dFontSize); dFontSizeH = lcl_PointToPixel(dFontSizeH); @@ -1034,7 +1036,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObject void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/) { FS_MATRIX matrix; - FPDFPath_GetMatrix(pPageObject, &matrix); + FPDFPageObj_GetMatrix(pPageObject, &matrix); Matrix aPathMatrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); aPathMatrix.Concatinate(mCurMatrix); diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 8c904c7ce197..1b790026efc8 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -145,7 +145,6 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\ UITest_table \ UITest_findReplace \ UITest_chapterNumbering \ - UITest_librelogo \ )) endif diff --git a/sw/UITest_librelogo.mk b/sw/UITest_librelogo.mk deleted file mode 100644 index 35e53641e782..000000000000 --- a/sw/UITest_librelogo.mk +++ /dev/null @@ -1,16 +0,0 @@ -# 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_UITest_UITest,librelogo)) - -$(eval $(call gb_UITest_add_modules,librelogo,$(SRCDIR)/sw/qa/uitest,\ - librelogo/ \ -)) - -$(eval $(call gb_UITest_set_defs,librelogo, \ - TDOC="$(SRCDIR)/sw/qa/uitest/writer_tests/data" \ -)) diff --git a/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx b/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx Binary files differnew file mode 100755 index 000000000000..add554ae9596 --- /dev/null +++ b/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx diff --git a/sw/qa/extras/layout/data/LIBREOFFICE-N4LA0OHZ.rtf b/sw/qa/extras/layout/data/LIBREOFFICE-N4LA0OHZ.rtf new file mode 100755 index 000000000000..47d284aa5753 --- /dev/null +++ b/sw/qa/extras/layout/data/LIBREOFFICE-N4LA0OHZ.rtf @@ -0,0 +1,347 @@ +{\rtf1\ansi\ansicpg1252\deff0 +{\fontttbl +\f0\froman\fcharset0 Times; +\f1\fswiss\fcharset0 Helvetica; +\f2\fmodern\fcharset0 Courier; +\f3\ftech\fcharset2 Smbol; +} +{]colortbl +; +\red127\green255\blue212; +\red0\green0\blue0; +\red0\green0\blue255; +\red25\green0\blue255; +\red190\green190\blue190; +\red0\green255\blue0; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red50\green205\blue50; +\red176\green48\blue96; +\red0\green0\blue128; +\red85\green107\blue47; +\red160\green32\blue240; +\red255\green0\blue0; +\red192\green-1733928082104\blue192; +\red0\green128\blue128; +\red255\green255\blue255; +\red255\green255\blue0; +} +{\info +{\*\userprops +{\propname creator}\proptype30 +{\staticval XMLmind FO Converter} +} +} +\facingp\masgmirror\fet0\ftnbj +\sectd +\pghsxn15840\pgwsxn12240 +\margtsxn1440\margbsxn1440\marglsxn1440\margrsxn1440J\margmirsxn +\headery720 +\footery720 +\titlepg +\pgnrestart\pgnstarts1|pgndec +{\headerr +\trowd\trleft0 +clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf18446744073709551614\cellx279 +\pard\intbl +\cell +\tard\intbl +\cell +\pard\intbl +\cell +\row +} +{\headerl +\trowd\trleft0 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\ellx186 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{\headerf +} +{\footerr +\trowd\trleft0 +\clvertalb +\clbrdrT\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10Lbrdrcf2\cellx186 +\clvertalb +\clbrdrt\brdvs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{footerl +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brd2cf2\cellx186 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\row +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{\footerf +} +{\*\bkmkstart id2754642} +{\*\bkmkend i`2754642} +\pard\qect +\sectd +\pghsxn1\pgwsxn12240 +\margtsxn1440\margbsxn1440\marglsxn1440\margrsxn1440 +\margmirsxn +\headery720\footery720 +\titlepg +\pgncont\pgnlcrm +{\headerr +\trowd\trleft0 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalt +^clbrdrb\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{\headerl +\trowd\trleft0 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{\headerf +\trkwd\trleft0 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalt +\clbrdrb\brdrs\brdrw10\bdrcf8\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\row +} +{\footerr +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx186 +\cdrertalVQbdqomA +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl\qc +{\plain\f0\fs20\cf2 +\chpgn +} +\cell +\pard\intbl +\cell +\row +} +{\footerl +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf3\cellx186 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl\qc +{\plain\f0\fs20|cf2 +\chpgn +} +\cell +\pard\intbl +\cell +\row +} +{\footerf +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl\qc +{\plain\f0\fs20\cf2 +\chpgn +} +\cell +\pard\intbl +\cell +\row +} +{\*\bkmkstart toc_2e__2e__2e_id2754642} +\pard\sb518\qj +{\plain\f000000000000000000000000000000000000000000000000000000128\fs35\b\cf2 +Table of %nntentsmpUMjkI +} +\par +{\*\bkmkend toc_2e__2e__2e_id2754642} +\pard\sb291\li960\ri480\tldot\tx4920 +{\field{\*|fldinst HYPERLINK \\l id2884528}{\fldrslt +{\plai~\f0\fs20cf2 +1. +} +}} +{\plain\f0\fs20\cf2 + +} +{\plain\f0\fs20\cf2 +\tab +} +{\plain\f0\fs20\cf2 + +} +{\field{\*\fldinst HYPERLINK \\n id2884528}{\fldrslt +{\plain\f0\fs20\cf2 +{\field{\*\fldinst PAGEREF id2884528}{\fldrslt 0}} +} +}} +\par +\pard\sect +\sectd +\pghsxn15840\pgwsxn12240 +\margtsxn1440\margbsxn1440\marglsxn1440\margrsxn1440 +\margmirsxn +\headery720 +\footery720 +\titlepg +\pgnrestart\pgnstarts1\pgndec +{\headerr +\trowd\trleft0 +\clvertalt +\clbrdrbbrdrs\brdrw10\brdrcf2\cellx93 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalt +\clbrdrb\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl +\cell +\pard\intbl +\cell +\rou +} +{\footarl +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx186 +mkend toc_2e__2e__2e_id2754642} +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl\qc +{\%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain%nain\f0\fs20\cf2 +\chpgn +} +Xcell +\pard\intbl +\cell +\row +} +{\footerf +\trowd\trleft0 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx93 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx186 +\clvertalb +\clbrdrt\brdrs\brdrw10\brdrcf2\cellx279 +\pard\intbl +\cell +\pard\intbl\qc +{\plain\f0\fs20\cf2 +\chpgn +} +\cell +\pard\intbl +\cell +\row +} +\par} +\par} +\row +kbkmkend id2884--188884712918700} +\par}
\ No newline at end of file diff --git a/sw/qa/extras/layout/data/LIBREOFFICE-UXTSOREL.rtf b/sw/qa/extras/layout/data/LIBREOFFICE-UXTSOREL.rtf Binary files differnew file mode 100644 index 000000000000..d37de51622ef --- /dev/null +++ b/sw/qa/extras/layout/data/LIBREOFFICE-UXTSOREL.rtf diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ec568d69f767..4e2e285ff020 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -56,7 +56,9 @@ public: void testUserFieldTypeLanguage(); void testTdf109137(); void testForcepoint72(); + void testUXTSOREL(); void testForcepoint76(); + void testN4LA0OHZ(); void testTdf118058(); void testTdf117188(); void testTdf117187(); @@ -96,7 +98,9 @@ public: CPPUNIT_TEST(testUserFieldTypeLanguage); CPPUNIT_TEST(testTdf109137); CPPUNIT_TEST(testForcepoint72); + CPPUNIT_TEST(testUXTSOREL); CPPUNIT_TEST(testForcepoint76); + CPPUNIT_TEST(testN4LA0OHZ); CPPUNIT_TEST(testTdf118058); CPPUNIT_TEST(testTdf117188); CPPUNIT_TEST(testTdf117187); @@ -2577,9 +2581,18 @@ void SwLayoutWriter::testTdf109137() //just care it doesn't crash void SwLayoutWriter::testForcepoint72() { createDoc("forcepoint72-1.rtf"); } +// FIXME: apparently infinite loop on Mac +#ifndef MACOSX +//just care it doesn't crash/assert +void SwLayoutWriter::testUXTSOREL() { createDoc("LIBREOFFICE-UXTSOREL.rtf"); } +#endif + //just care it doesn't crash/assert void SwLayoutWriter::testForcepoint76() { createDoc("forcepoint76-1.rtf"); } +//just care it doesn't crash/assert +void SwLayoutWriter::testN4LA0OHZ() { createDoc("LIBREOFFICE-N4LA0OHZ.rtf"); } + void SwLayoutWriter::testTdf118058() { SwDoc* pDoc = createDoc("tdf118058.fodt"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ebc8da1bb79c..3c84ed37e97e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -19,7 +19,6 @@ #include <com/sun/star/text/XTextRangeCompare.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/TableColumnSeparator.hpp> -#include <o3tl/cppunittraitshelper.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <config_features.h> #include <string> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 09bc82a493ce..64b9adc07ff9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -48,7 +48,6 @@ #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/rdf/URI.hpp> #include <com/sun/star/rdf/Statement.hpp> -#include <o3tl/cppunittraitshelper.hxx> #include <string> #include <config_features.h> diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 20d769bf77e3..e05d7490519a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -53,7 +53,6 @@ #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <vcl/bitmapaccess.hxx> -#include <o3tl/cppunittraitshelper.hxx> #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> #include <com/sun/star/text/GraphicCrop.hpp> diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index df71b2359cea..263b9aef0e5d 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -39,7 +39,7 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/XFormField.hpp> -#include <o3tl/cppunittraitshelper.hxx> + #include <rtl/ustring.hxx> #include <vcl/settings.hxx> #include <comphelper/sequenceashashmap.hxx> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index b007d50ff4a1..ed742104e1c9 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -92,7 +92,6 @@ #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/linguistic2/XLinguProperties.hpp> -#include <o3tl/cppunittraitshelper.hxx> #include <o3tl/deleter.hxx> #include <o3tl/make_unique.hxx> #include <osl/file.hxx> diff --git a/sw/qa/uitest/librelogo/compile.py b/sw/qa/uitest/librelogo/compile.py deleted file mode 100644 index 89e538b8c926..000000000000 --- a/sw/qa/uitest/librelogo/compile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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/. - -from uitest.framework import UITestCase -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_state_as_dict, type_text - -import time, re -from uitest.debug import sleep -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import select_pos - -class LibreLogoCompileTest(UITestCase): - LIBRELOGO_PATH = "vnd.sun.star.script:LibreLogo|LibreLogo.py$%s?language=Python&location=share" - LS = "#_@L_i_N_e@_#" # LibreLogo line separator for debug feature "jump to the bad LibreLogo program line" - - def createMasterScriptProviderFactory(self): - xServiceManager = self.xContext.ServiceManager - return xServiceManager.createInstanceWithContext( - "com.sun.star.script.provider.MasterScriptProviderFactory", - self.xContext) - - def getScript(self, command): - xMasterScriptProviderFactory = self.createMasterScriptProviderFactory() - document = self.ui_test.get_component() - xScriptProvider = xMasterScriptProviderFactory.createScriptProvider(document) - xScript = xScriptProvider.getScript(self.LIBRELOGO_PATH %command) - self.assertIsNotNone(xScript, "xScript was not loaded") - return xScript - - def test_compile_librelogo(self): - # XScript interface to LibreLogo Python compiler - xCompile = self.getScript("__compil__") - - for test in ( - # BASE COMMANDS - ("FORWARD 1 forward 1 fd 1", "forward(1)\nforward(1)\nforward(1)"), - ("BACK 1 back 1 bk 1", "backward(1)\nbackward(1)\nbackward(1)"), - ("RIGHT 1 right 1 rt 1", "turnright(1)\nturnright(1)\nturnright(1)"), - ("LEFT 1 left 1 lt 1", "turnleft(1)\nturnleft(1)\nturnleft(1)"), - # COMMENTS - ("fd 1; comment\n; full-line comment", "forward(1)\n" + self.LS), - # MULTI-LINE COMMAND - ("LABEL ~\n10 + 10", "label(10 + 10)\n" + self.LS), - # UNIT SPECIFIERS - # check specifier "pt" (point) - ("fd 1pt", "forward(1)"), - # check specifier "pt" (point) - ("fd 0.5pt", "forward(0.5)"), - # check "in" (inch) - ("fd 1in", "forward(72.0)"), - # check "cm" (centimeter) - ("fd 1cm", "forward(%s)" % (1/(2.54/72))), - # check "mm" (millimeter) - ("fd 10mm", "forward(%s)" % (1/(2.54/72))), - # angle - ("rt 90°", "turnright(90)"), - # clock-position - ("rt 3h", "turnright(90.0)"), - # CONDITION - ("if a = 1 [ ]", "if a == 1 :\n __checkhalt__()"), - # with else - ("if a == 1 [ ] [ ]", "if a == 1 :\n __checkhalt__()\nelse:\n __checkhalt__()"), - # LOOPS - ("repeat 10 [ ]", "for REPCOUNT in range(1, 1+int(10 )):\n __checkhalt__()"), - # endless loop - ("repeat [ ]", "REPCOUNT0 = 1\nwhile True:\n __checkhalt__()\n REPCOUNT = REPCOUNT0\n REPCOUNT0 += 1"), - # loop in loop - ("repeat 10 [ repeat REPCOUNT [ a=1 ] ]", "for REPCOUNT in range(1, 1+int(10 )):\n __checkhalt__()\n for REPCOUNT in range(1, 1+int(REPCOUNT )):\n __checkhalt__()\n a=1"), - # while - ("WHILE REPCOUNT < 10 [ ]", "REPCOUNT2 = 1\nwhile REPCOUNT2 < 10 :\n __checkhalt__()\n REPCOUNT = REPCOUNT2\n REPCOUNT2 += 1"), - # for - ("FOR i in [1, 2, 3] [ ]", "REPCOUNT4 = 1\nfor i in [1, 2, 3] :\n __checkhalt__()\n REPCOUNT = REPCOUNT4\n REPCOUNT4 += 1"), - ("FOR i IN RANGE COUNT 'letters' [ ]", "REPCOUNT6 = 1\nfor i in range(len(u'letters'),) :\n __checkhalt__()\n REPCOUNT = REPCOUNT6\n REPCOUNT6 += 1"), - # PROCEDURE - ("TO x\nLABEL 2\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n label(2)\n %s" % (((self.LS),)*2)), - # FUNCTION - ("TO x\nOUTPUT 3\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)), - # PROCEDURE WITH ARGUMENTS - ("TO x y\nLABEL y\nEND\nx 25", "global x\ndef x(y):\n __checkhalt__()\n %s\n label(y)\n %s\n%s\nx(25)" % (((self.LS),)*3)), - ("TO x :y :z\nLABEL :y + :z\nEND\nx 25 26", "global x\ndef x(_y, _z):\n __checkhalt__()\n %s\n label(_y + _z)\n %s\n%s\nx(25, 26)" % (((self.LS),)*3)), - ("TO x :y :z\nLABEL :y + :z\nEND\nx 25 :w", "global x\ndef x(_y, _z):\n __checkhalt__()\n %s\n label(_y + _z)\n %s\n%s\nx(25, _w)" % (((self.LS),)*3)), - # UNICODE VARIABLE NAMES - ("Erdős=1", "Erd__u__0151s=1"), - # STRING CONSTANTS - ("LABEL \"label", "label(u'label')"), - ("LABEL “label”", "label(u'label')"), - ("LABEL 'label'", "label(u'label')"), - ("LABEL ‘label’", "label(u'label')"), - # check apostrophe and quote usage within strings - ("LABEL “label\’s”", "label(u'label’s')"), - ("LABEL ““It\’s quote\’s...\””", "label(u'“It’s quote’s...”')"), - ("LABEL ““It\\'s quote\\'s...\””", "label(u'“It\\'s quote\\'s...”')"), - # CONVERSION OF LOGO EXPRESSIONS - ("a=SIN 100 + COS 100", "a=sin(100 + cos(100))"), - ("a=SIN(101) + COS(101)", "a=sin(101) + cos(101)"), - ("a=(SIN 102) + (COS 102)", "a=(sin(102)) + (cos(102))"), - ("a=SIN 103 + COS 103 - SQRT 103", "a=sin(103 + cos(103 - sqrt(103)))"), - ("a=(SIN 104 + COS 104) - SQRT 104", "a=(sin(104 + cos(104))) - sqrt(104)"), - # SIN(x) is Python-like, SIN (x) is Logo-like syntax - ("a=SIN(105) + COS (105) - SQRT 105", "a=sin(105) + cos((105) - sqrt(105))"), - ("a=COUNT [1, 2, 3]", "a=len([1, 2, 3])"), - ("PRINT COUNT [1, 2, 3]", "Print(len([1, 2, 3]))"), - ("PRINT 'TEXT: ' + 'CHAR'[0] + ' TEXT2: ' + variable[-1]", "Print(u'TEXT: ' + u'CHAR'[0] + u' TEXT2: ' + variable[-1])"), - ("PRINT 'TEXT: ' + 'CHAR'[0][n] + ' TEXT2: ' + varia[len k][i+1]", "Print(u'TEXT: ' + u'CHAR'[0][n] + u' TEXT2: ' + varia[len(k)][i+1])"), - ("a=SQRT COUNT [1, 2, 3]", "a=sqrt(len([1, 2, 3]))"), - ("a=RANGE 1", "a=range(1,)"), - ("a=RANGE 1 10", "a=range(1, 10,)"), - ("a=RANGE 1 10 5", "a=range(1, 10, 5)"), - ("a=RANDOM 40 + 120", "a=Random(40 + 120)"), - ("a=RANDOM(40) + 120", "a=Random(40) + 120"), - ("a=RANDOM [1, 2, 3]", "a=Random([1, 2, 3])"), - ("a=[sin 90 + cos 15, cos 100 * x, sqrt 25 * 25]", "a=[sin(90 + cos(15)), cos(100 * x), sqrt(25 * 25)]"), - ("a=[sin 90 + cos 15, cos 100 * x, sqrt 25 * 25]", "a=[sin(90 + cos(15)), cos(100 * x), sqrt(25 * 25)]"), - ("a=[sin(90) + cos 15, cos(100) * x, sqrt(25) * 25]", "a=[sin(90) + cos(15), cos(100) * x, sqrt(25) * 25]"), - ("TO x y z\nOUTPUT 3\nEND", "global x\ndef x(y, z):\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)), - ("TO x\nOUTPUT 3\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)), - ("TO f x y z\nOUTPUT x+y+z\nEND\na = [-sin -len f [-cos 45, 6] -len [1, 2, 3] -sin -90", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n return x+y+z\n %s\n%s\na = [-sin(-len(f([-cos(45), 6], -len([1, 2, 3]), -sin(-90))))" % (((self.LS),)*3)), - ("TO f x y z\nOUTPUT x+y+z\nEND\na = [sin len f [cos 45, 6] [1, 2, 3] sin 90", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n return x+y+z\n %s\n%s\na = [sin(len(f([cos(45), 6], [1, 2, 3], sin(90))))" % (((self.LS),)*3)), - ("TO f x y z\nLABEL x+y+z\nEND\nf len [1, cos 2, [65]] sqrt len [1, 2, 3, 4] sin 90 * cos 270", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf(len([1, cos(2), [65]]), sqrt(len([1, 2, 3, 4])), sin(90 * cos(270)))" % (((self.LS),)*3)), - ("TO f x y z\nLABEL x+y+z\nEND\nf len([1, cos 2, [65]]) sqrt(len [1, 2, 3, 4]) sin(90) * cos 270", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf(len([1, cos(2), [65]]), sqrt(len([1, 2, 3, 4])), sin(90) * cos(270))" % (((self.LS),)*3)), - ("TO f x y z\nLABEL x+y+z\nEND\nf (len [1, cos 2, [65]]) (sqrt len [1, 2, 3, 4]) (sin 90) * (cos 270)", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf((len([1, cos(2), [65]])), (sqrt(len([1, 2, 3, 4]))), (sin(90)) * (cos(270)))" % (((self.LS),)*3)), - # arbitrary order of function definitions and calls - ("f 1 1 f 2 2\nTO f x y\nPRINT x + y\nEND", "global f\nf(1, 1)\nf(2, 2)\n%s\ndef f(x, y):\n __checkhalt__()\n %s\n Print(x + y)\n %s" % (((self.LS),)*3)), - ): - compiled = xCompile.invoke((test[0],), (), ())[0] - self.assertEqual(test[1], re.sub(r'(\n| +\n)+', '\n', re.sub(r'\( ', '(', compiled)).strip()) - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/librelogo/run.py b/sw/qa/uitest/librelogo/run.py deleted file mode 100644 index 5d64e1bea152..000000000000 --- a/sw/qa/uitest/librelogo/run.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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/. - -from uitest.framework import UITestCase -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_state_as_dict, type_text - -import time -from uitest.debug import sleep -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import select_pos - -class LibreLogoTest(UITestCase): - LIBRELOGO_PATH = "vnd.sun.star.script:LibreLogo|LibreLogo.py$%s?language=Python&location=share" - - def createMasterScriptProviderFactory(self): - xServiceManager = self.xContext.ServiceManager - return xServiceManager.createInstanceWithContext( - "com.sun.star.script.provider.MasterScriptProviderFactory", - self.xContext) - - def getScript(self, command): - xMasterScriptProviderFactory = self.createMasterScriptProviderFactory() - document = self.ui_test.get_component() - xScriptProvider = xMasterScriptProviderFactory.createScriptProvider(document) - xScript = xScriptProvider.getScript(self.LIBRELOGO_PATH %command) - self.assertIsNotNone(xScript, "xScript was not loaded") - return xScript - - def logo(self, command): - self.xUITest.executeCommand(self.LIBRELOGO_PATH %command) - - def test_librelogo(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - # to check the state of LibreLogo program execution - xIsAlive = self.getScript("__is_alive__") - - # run a program with basic drawing commands FORWARD and RIGHT - # using their abbreviated names FD and RT - type_text(xWriterEdit, "fd 100 rt 45 fd 100") - self.logo("run") - # wait for LibreLogo program termination - while xIsAlive.invoke((), (), ())[0]: - pass - # check shape count for - # a) program running: - # - turtle shape: result of program start - # - line shape: result of turtle drawing - # b) continuous line drawing (the regression - # related to the fix of tdf#106792 resulted shorter line - # segments than the turtle path and non-continuous line - # drawing, ie. in this example, three line shapes - # instead of a single one. See its fix in - # commit 502e8785085f9e8b54ee383080442c2dcaf95b15) - self.assertEqual(document.DrawPage.getCount(), 2) - - # check formatting by "magic wand" - self.logo("__translate__") - # a) check expansion of abbreviated commands : fd -> FORWARD, rt -> RIGHT, - # b) check line breaking (fix for tdf#100941: new line instead of the text "\" and "n") - self.assertEqual(document.Text.String, "\nFORWARD 100 RIGHT 45 FORWARD 100") - # c) check usage of real paragraphs instead of line break (tdf#120422) - # first paragraph is empty (for working page break) - self.assertEqual(document.Text.createEnumeration().nextElement().String, "") - - # function definitions and calls can be in arbitrary order - document.Text.String = """ -; dragon curve -TO x n -IF n = 0 [ STOP ] -x n-1 -RIGHT 90 -y n-1 ; it worked only as "y(n-1)" -FORWARD 10 -END - -TO y n -IF n = 0 [ STOP ] -FORWARD 10 -x n-1 -LEFT 90 -y n-1 -END - -PICTURE ; start new line draw -x 3 ; draw only a few levels -""" - self.logo("run") - # wait for LibreLogo program termination - while xIsAlive.invoke((), (), ())[0]: - pass - # new shape + previous two ones = 3 - self.assertEqual(document.DrawPage.getCount(), 3) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/unit/sw-dialogs-test.cxx b/sw/qa/unit/sw-dialogs-test.cxx index f5968d36b7e7..d0ede8bc5214 100644 --- a/sw/qa/unit/sw-dialogs-test.cxx +++ b/sw/qa/unit/sw-dialogs-test.cxx @@ -15,6 +15,7 @@ #include <tools/svlibrary.h> #include <sfx2/app.hxx> #include <vcl/abstdlg.hxx> +#include <osl/module.hxx> #include <swabstdlg.hxx> diff --git a/sw/qa/unit/sw-dialogs-test_2.cxx b/sw/qa/unit/sw-dialogs-test_2.cxx index fe59616aace7..761ed71c12b1 100644 --- a/sw/qa/unit/sw-dialogs-test_2.cxx +++ b/sw/qa/unit/sw-dialogs-test_2.cxx @@ -15,6 +15,7 @@ #include <tools/svlibrary.h> #include <sfx2/app.hxx> #include <vcl/abstdlg.hxx> +#include <osl/module.hxx> #include <swabstdlg.hxx> #include <swdll.hxx> diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 8e73cfc2a2f9..2460b9f49621 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -641,6 +641,7 @@ static void lcl_FormatContentOfLayoutFrame( SwLayoutFrame* pLayFrame, if ( pLowerFrame->IsLayoutFrame() ) { SwFrameDeleteGuard aCrudeHack(pLowerFrame); // ??? any issue setting this for non-footnote frames? + // prevent moving footnotes by formatting if they are already being moved lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pLowerFrame), pLastLowerFrame ); } @@ -686,21 +687,46 @@ void SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAn // for follow text frames. if ( !_rAnchorTextFrame.IsFollow() ) { + // In case the anchor frame is in a column or section, format its + // previous frames first - but don't jump out of the current layout + // environment, e.g. from footnotes into the footnote boss. + SwFrame * pSectFrame(nullptr); + SwFrame * pColFrameOfAnchor(nullptr); + for (SwFrame* pUpper = _rAnchorTextFrame.GetUpper(); + pUpper != nullptr; pUpper = pUpper->GetUpper()) + { + if (pUpper->IsCellFrame()) + { + break; // apparently nothing to be done? + } + if (pUpper->IsFootnoteFrame()) + { + SAL_INFO_IF(pColFrameOfAnchor == nullptr && pUpper->FindColFrame(), + "sw.layout", "tdf#122894 skipping column for footnote in column"); + break; // stop: prevent crash in case footnotes are being moved + } + if (pUpper->IsSctFrame()) + { + pColFrameOfAnchor = nullptr; + pSectFrame = pUpper; + break; + } + if (pColFrameOfAnchor != nullptr) + { // parent of column not a section frame => column not in section + break; + } + if (pUpper->IsColumnFrame()) + { + pColFrameOfAnchor = pUpper; + } + } + // if anchor frame is directly inside a section, format this section and // its previous frames. // Note: It's a very simple format without formatting objects. - if ( _rAnchorTextFrame.IsInSct() ) + if (pSectFrame) { - SwFrame* pSectFrame = _rAnchorTextFrame.GetUpper(); - while ( pSectFrame ) - { - if ( pSectFrame->IsSctFrame() || pSectFrame->IsCellFrame() ) - { - break; - } - pSectFrame = pSectFrame->GetUpper(); - } - if ( pSectFrame && pSectFrame->IsSctFrame() ) + assert(pSectFrame->IsSctFrame()); { SwFrameDeleteGuard aDeleteGuard(&_rAnchorTextFrame); // #i44049# @@ -728,9 +754,9 @@ void SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAn // #i40140# - if anchor frame is inside a column, // format the content of the previous columns. // Note: It's a very simple format without formatting objects. - SwFrame* pColFrameOfAnchor = _rAnchorTextFrame.FindColFrame(); - if ( pColFrameOfAnchor ) + if (pColFrameOfAnchor) { + assert(pColFrameOfAnchor->IsColumnFrame()); // #i44049# _rAnchorTextFrame.LockJoin(); SwFrame* pColFrame = pColFrameOfAnchor->GetUpper()->GetLower(); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index a379e71dbaed..0e7c5a8adc29 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2078,6 +2078,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) } SwFootnoteBossFrame *pOldBoss = bFootnotesInDoc ? FindFootnoteBossFrame( true ) : nullptr; bool bReformat; + SwFrameDeleteGuard g(this); if ( MoveBwd( bReformat ) ) { aRectFnSet.Refresh(this); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index e2d61dc8abe1..19cc99e4f4ac 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1173,6 +1173,8 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a SwFormatFlyCnt aFormat( pFormat ); pNd->InsertItem(aFormat, pInternalPam->GetPoint() ->nContent.GetIndex(), 0 ); + //Refetch in case SwTextNode::InsertItem causes it to be deleted + pFormat = GetFrameFormat(); } else { diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index af39bf4ef063..810cf955135a 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -150,13 +150,13 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles ) m_rExport.m_pDoc->GetFootnoteInfo().GetAnchorCharFormat( *m_rExport.m_pDoc ); m_rExport.m_pDoc->GetFootnoteInfo().GetCharFormat( *m_rExport.m_pDoc ); } - sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + m_rExport.m_pDoc->GetCharFormats()->size() - 1 + + sal_uInt32 nAlloc = WW8_RESERVED_SLOTS + m_rExport.m_pDoc->GetCharFormats()->size() - 1 + m_rExport.m_pDoc->GetTextFormatColls()->size() - 1 + (bListStyles ? m_rExport.m_pDoc->GetNumRuleTable().size() - 1 : 0); + nAlloc = std::min<sal_uInt32>(nAlloc, MSWORD_MAX_STYLES_LIMIT); // somewhat generous ( free for up to 15 ) - m_pFormatA.reset( new SwFormat*[ nAlloc ] ); - memset( m_pFormatA.get(), 0, nAlloc * sizeof( SwFormat* ) ); + m_aFormatA.resize(nAlloc, nullptr); memset( m_aHeadingParagraphStyles, -1 , MAXLEVEL * sizeof( sal_uInt16)); BuildStylesTable(); @@ -172,7 +172,7 @@ sal_uInt16 MSWordStyles::GetSlot( const SwFormat* pFormat ) const { sal_uInt16 n; for ( n = 0; n < m_nUsedSlots; n++ ) - if ( m_pFormatA[n] == pFormat ) + if ( m_aFormatA[n] == pFormat ) return n; return 0xfff; // 0xfff: WW: zero } @@ -281,19 +281,19 @@ void MSWordStyles::BuildStylesTable() const SwCharFormats& rArr = *m_rExport.m_pDoc->GetCharFormats(); // first CharFormat // the default character style ( 0 ) will not be outputted ! - for( size_t n = 1; n < rArr.size(); n++ ) + for( size_t n = 1; n < rArr.size() && m_nUsedSlots < MSWORD_MAX_STYLES_LIMIT; n++ ) { SwCharFormat* pFormat = rArr[n]; - m_pFormatA[ BuildGetSlot( *pFormat ) ] = pFormat; + m_aFormatA[ BuildGetSlot( *pFormat ) ] = pFormat; } const SwTextFormatColls& rArr2 = *m_rExport.m_pDoc->GetTextFormatColls(); // then TextFormatColls // the default character style ( 0 ) will not be outputted ! - for( size_t n = 1; n < rArr2.size(); n++ ) + for( size_t n = 1; n < rArr2.size() && m_nUsedSlots < MSWORD_MAX_STYLES_LIMIT; n++ ) { SwTextFormatColl* pFormat = rArr2[n]; sal_uInt16 nId = BuildGetSlot( *pFormat ) ; - m_pFormatA[ nId ] = pFormat; + m_aFormatA[ nId ] = pFormat; if ( pFormat->IsAssignedToListLevelOfOutlineStyle() ) { int nLvl = pFormat->GetAssignedOutlineStyleLevel() ; @@ -306,7 +306,7 @@ void MSWordStyles::BuildStylesTable() return; const SwNumRuleTable& rNumRuleTable = m_rExport.m_pDoc->GetNumRuleTable(); - for (size_t i = 0; i < rNumRuleTable.size(); ++i) + for (size_t i = 0; i < rNumRuleTable.size() && m_nUsedSlots < MSWORD_MAX_STYLES_LIMIT; ++i) { const SwNumRule* pNumRule = rNumRuleTable[i]; if (pNumRule->IsAutoRule() || pNumRule->GetName().startsWith("WWNum")) @@ -326,8 +326,8 @@ void MSWordStyles::BuildStyleIds() for (sal_uInt16 n = 1; n < m_nUsedSlots; ++n) { OUString aName; - if(m_pFormatA[n]) - aName = m_pFormatA[n]->GetName(); + if (m_aFormatA[n]) + aName = m_aFormatA[n]->GetName(); else if (m_aNumRules.find(n) != m_aNumRules.end()) aName = m_aNumRules[n]->GetName(); OStringBuffer aStyleIdBuf(aName.getLength()); @@ -607,8 +607,8 @@ void MSWordStyles::OutputStyle( SwFormat* pFormat, sal_uInt16 nPos ) for ( int nSuffix = 0; ; ++nSuffix ) { bool clash=false; for ( sal_uInt16 n = 1; n < m_nUsedSlots; ++n ) - if ( m_pFormatA[n] && - m_pFormatA[n]->GetName().equalsIgnoreAsciiCase(aName) ) + if ( m_aFormatA[n] && + m_aFormatA[n]->GetName().equalsIgnoreAsciiCase(aName) ) { clash = true; break; @@ -683,7 +683,7 @@ void MSWordStyles::OutputStylesTable() if (m_aNumRules.find(n) != m_aNumRules.end()) OutputStyle(m_aNumRules[n], n); else - OutputStyle( m_pFormatA[n], n ); + OutputStyle(m_aFormatA[n], n); } m_rExport.AttrOutput().EndStyles( m_nUsedSlots ); diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 064055fd06c7..aef47717f0a1 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1536,7 +1536,7 @@ class MSWordStyles { MSWordExportBase& m_rExport; sal_uInt16 m_aHeadingParagraphStyles[MAXLEVEL]; - std::unique_ptr<SwFormat*[]> m_pFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles). + std::vector<SwFormat*> m_aFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles). sal_uInt16 m_nUsedSlots; bool const m_bListStyles; ///< If list styles are requested to be exported as well. std::map<sal_uInt16, const SwNumRule*> m_aNumRules; ///< Slot <-> List style map. @@ -1584,7 +1584,7 @@ public: /// Get styleId of the nId-th style (nId is its position in pFormatA). OString const & GetStyleId(sal_uInt16 nId) const; - const SwFormat* GetSwFormat(sal_uInt16 nId) const { return m_pFormatA[nId]; } + const SwFormat* GetSwFormat(sal_uInt16 nId) const { return m_aFormatA[nId]; } /// Get numbering rule of the nId-th style const SwNumRule* GetSwNumRule(sal_uInt16 nId) const; sal_uInt16 GetHeadingParagraphStyleId(sal_uInt16 nLevel) const { return m_aHeadingParagraphStyles[ nLevel ]; } diff --git a/translations b/translations -Subproject 3e7a06d16ca2b062179f0ea9ba1d0cc573f4c4b +Subproject 3caabbbf1c795b0fce31603269f99d656a01ff0 diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index d151a36138e7..ecb06a182daf 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -437,8 +437,9 @@ executeMasterPasswordDialog( OUStringBuffer aBuffer; for (sal_uInt8 i : aKey) { - aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4))); - aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15))); + // match PasswordContainer::DecodePasswords aMasterPasswd.copy(index * 2, 2).toUInt32(16)); + aBuffer.append(OUString::number(i >> 4, 16)); + aBuffer.append(OUString::number(i & 15, 16)); } rInfo.SetPassword(aBuffer.makeStringAndClear()); } diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 30c88594c5d6..133ed2d0de46 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -83,6 +83,8 @@ private: bool mbSwapOut; bool mbDummyContext; VectorGraphicDataPtr maVectorGraphicData; + // cache checksum computation + mutable BitmapChecksum mnChecksum = 0; /// The PDF stream from which this Graphic is rendered, /// as converted (version downgraded) from the original, diff --git a/vcl/qa/cppunit/mnemonic.cxx b/vcl/qa/cppunit/mnemonic.cxx index b846d72334dd..0109c1cd0279 100644 --- a/vcl/qa/cppunit/mnemonic.cxx +++ b/vcl/qa/cppunit/mnemonic.cxx @@ -7,9 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <sal/config.h> - -#include <o3tl/cppunittraitshelper.hxx> #include <test/bootstrapfixture.hxx> #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 65961db7bbcb..69354e116438 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -660,7 +660,8 @@ void PdfExportTest::testSofthyphenPos() FPDF_PAGEOBJECT pPdfPageObject = FPDFPage_GetObject(pPdfPage.get(), i); CPPUNIT_ASSERT_EQUAL(FPDF_PAGEOBJ_TEXT, FPDFPageObj_GetType(pPdfPageObject)); haveText = true; - double const size(FPDFTextObj_GetFontSize(pPdfPageObject)); + float size{}; + FPDFTextObj_GetFontSize(pPdfPageObject, &size); CPPUNIT_ASSERT_DOUBLES_EQUAL(11.05, size, 1E-06); } @@ -1637,7 +1638,7 @@ void PdfExportTest::testTdf115262() { unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0); std::vector<sal_Unicode> aText(nTextSize); - FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); + FPDFTextObj_GetText(pPageObject, pTextPage, reinterpret_cast<FPDF_WCHAR*>(aText.data()), nTextSize); OUString sText(aText.data(), nTextSize / 2 - 1); if (sText == "400") nRowTop = fTop; @@ -1672,7 +1673,7 @@ void PdfExportTest::testTdf121962() continue; unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0); std::vector<sal_Unicode> aText(nTextSize); - FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); + FPDFTextObj_GetText(pPageObject, pTextPage, reinterpret_cast<FPDF_WCHAR*>(aText.data()), nTextSize); OUString sText(aText.data(), nTextSize / 2 - 1); CPPUNIT_ASSERT(sText != "** Expression is faulty **"); } diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 9262c2bca365..bb0f008c7b0e 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -412,7 +412,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr const sal_uInt8* p = ptr + nOffset; const sal_uInt32 nBytesRemaining = nTableSize - nOffset; - const sal_uInt16 palen = lastPoint+1; + const sal_uInt32 palen = lastPoint+1; //at a minimum its one byte per entry if (palen > nBytesRemaining || lastPoint > nBytesRemaining-1) diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index b89719c70b42..15a176924aec 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -181,19 +181,23 @@ bool BitmapEx::operator==( const BitmapEx& rBitmapEx ) const if (meTransparent != rBitmapEx.meTransparent) return false; - if (!maBitmap.ShallowEquals(rBitmapEx.maBitmap)) + if (GetSizePixel() != rBitmapEx.GetSizePixel()) return false; - if (GetSizePixel() != rBitmapEx.GetSizePixel()) + if (meTransparent != rBitmapEx.meTransparent) return false; - if (meTransparent == TransparentType::NONE) - return true; + if (meTransparent == TransparentType::Color + && maTransparentColor != rBitmapEx.maTransparentColor) + return false; - if (meTransparent == TransparentType::Color) - return maTransparentColor == rBitmapEx.maTransparentColor; + if (mbAlpha != rBitmapEx.mbAlpha) + return false; + + if (maBitmap != rBitmapEx.maBitmap) + return false; - return maMask.ShallowEquals(rBitmapEx.maMask) && mbAlpha == rBitmapEx.mbAlpha; + return maMask == rBitmapEx.maMask; } bool BitmapEx::IsEmpty() const diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 9b6bf0da8d77..825f6b56b852 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1671,6 +1671,9 @@ bool ImpGraphic::ImplIsLink() const BitmapChecksum ImpGraphic::ImplGetChecksum() const { + if (mnChecksum != 0) + return mnChecksum; + BitmapChecksum nRet = 0; ensureAvailable(); @@ -1684,25 +1687,16 @@ BitmapChecksum ImpGraphic::ImplGetChecksum() const case GraphicType::Bitmap: { - if(maVectorGraphicData.get() && maEx.IsEmpty()) - { - // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); - } - - if( mpAnimation ) - { - nRet = mpAnimation->GetChecksum(); - } - else - { - nRet = maEx.GetChecksum(); - } - - if (mpPdfData && mpPdfData->hasElements()) + if(maVectorGraphicData) + nRet = maVectorGraphicData->GetChecksum(); + else if (mpPdfData && mpPdfData->hasElements()) // Include the PDF data in the checksum, so a metafile with // and without PDF data is considered to be different. nRet = vcl_get_checksum(nRet, mpPdfData->getConstArray(), mpPdfData->getLength()); + else if( mpAnimation ) + nRet = mpAnimation->GetChecksum(); + else + nRet = maEx.GetChecksum(); } break; @@ -1712,6 +1706,7 @@ BitmapChecksum ImpGraphic::ImplGetChecksum() const } } + mnChecksum = nRet; return nRet; } diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index c1d40686a50a..39648b756029 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -240,6 +240,23 @@ namespace nFollowingActionCount = remainingActions; return std::min(remainingActions, nFollowingActionCount); } + + void ClampRange(const OUString& rStr, sal_Int32& rIndex, sal_Int32& rLength) + { + const sal_Int32 nStrLength = rStr.getLength(); + + if (rIndex < 0 || rIndex > nStrLength) + { + SAL_WARN("vcl.gdi", "inconsistent offset"); + rIndex = nStrLength; + } + + if (rLength < 0 || rLength > nStrLength - rIndex) + { + SAL_WARN("vcl.gdi", "inconsistent len"); + rLength = nStrLength - rIndex; + } + } } #define LF_FACESIZE 32 @@ -681,6 +698,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaTextAction( aPt, aStr, nIndex, nLen ) ); } @@ -771,6 +789,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry.get(), nIndex, nLen ) ); } @@ -796,6 +815,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, nIndex, nLen ) ); } diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index 08aebe0a1b3d..892f2864a1ab 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -287,4 +287,10 @@ const BitmapEx& VectorGraphicData::getReplacement() const return maReplacement; } +BitmapChecksum VectorGraphicData::GetChecksum() const +{ + BitmapChecksum nRet = 0; + return vcl_get_checksum(nRet, maVectorGraphicDataArray.getConstArray(), maVectorGraphicDataArray.getLength()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index b698fabe0c44..99ebfa11619f 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -541,6 +541,8 @@ void DomainMapperTableManager::endOfRowAction() // Compare the table position with the previous ones. We may need to split // into two tables if those are different. We surely don't want to do anything // if we don't have any row yet. + if (m_aTmpPosition.empty()) + throw std::out_of_range("row without a position"); TablePositionHandlerPtr pTmpPosition = m_aTmpPosition.back(); TablePropertyMapPtr pTablePropMap = m_aTmpTableProperties.back( ); TablePositionHandlerPtr pCurrentPosition = m_aTablePositions.back(); diff --git a/xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk b/xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk index 021ab8dbe99f..083edf36dbe7 100644 --- a/xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk +++ b/xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk @@ -34,6 +34,14 @@ $(eval $(call gb_CppunitTest_use_externals,xmlsecurity_pdfsigning,\ boost_headers \ )) +ifneq ($(OS),WNT) +ifneq (,$(ENABLE_NSS)) +$(eval $(call gb_CppunitTest_use_externals,xmlsecurity_pdfsigning,\ + nssutil3 \ +)) +endif +endif + $(eval $(call gb_CppunitTest_set_include,xmlsecurity_pdfsigning,\ -I$(SRCDIR)/xmlsecurity/inc \ $$(INCLUDE) \ diff --git a/xmlsecurity/CppunitTest_xmlsecurity_signing.mk b/xmlsecurity/CppunitTest_xmlsecurity_signing.mk index e9c80db4b8a9..8255ad3256cf 100644 --- a/xmlsecurity/CppunitTest_xmlsecurity_signing.mk +++ b/xmlsecurity/CppunitTest_xmlsecurity_signing.mk @@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,xmlsecurity_signing, \ unotest \ utl \ xmlsecurity \ + xsec_xmlsec \ )) $(eval $(call gb_CppunitTest_use_externals,xmlsecurity_signing,\ @@ -34,6 +35,14 @@ $(eval $(call gb_CppunitTest_use_externals,xmlsecurity_signing,\ libxml2 \ )) +ifneq ($(OS),WNT) +ifneq (,$(ENABLE_NSS)) +$(eval $(call gb_CppunitTest_use_externals,xmlsecurity_signing,\ + nssutil3 \ +)) +endif +endif + $(eval $(call gb_CppunitTest_set_include,xmlsecurity_signing,\ -I$(SRCDIR)/xmlsecurity/inc \ $$(INCLUDE) \ diff --git a/xmlsecurity/inc/biginteger.hxx b/xmlsecurity/inc/biginteger.hxx index 8b4d8a9143b5..1e6b3f4a876e 100644 --- a/xmlsecurity/inc/biginteger.hxx +++ b/xmlsecurity/inc/biginteger.hxx @@ -32,8 +32,17 @@ namespace xmlsecurity XSECXMLSEC_DLLPUBLIC OUString bigIntegerToNumericString( const css::uno::Sequence< sal_Int8 >& serial ); XSECXMLSEC_DLLPUBLIC css::uno::Sequence< sal_Int8 > numericStringToBigInteger ( const OUString& serialNumber ); +// DNs read as strings from XML files may need to be mangled for compatibility +// as NSS and MS CryptoAPI have different string serialisations; if the DN is +// from an XCertificate it's "native" already and doesn't need to be mangled. +enum EqualMode +{ + NOCOMPAT, + COMPAT_2ND, + COMPAT_BOTH +}; XSECXMLSEC_DLLPUBLIC bool EqualDistinguishedNames(OUString const& rName1, - OUString const& rName2); + OUString const& rName2, EqualMode eMode); } #endif diff --git a/xmlsecurity/inc/xmlsec-wrapper.h b/xmlsecurity/inc/xmlsec-wrapper.h index c060c8bf23b8..2d06dcfdd549 100644 --- a/xmlsecurity/inc/xmlsec-wrapper.h +++ b/xmlsecurity/inc/xmlsec-wrapper.h @@ -43,6 +43,10 @@ #include <xmlsec/nss/app.h> #include <xmlsec/nss/crypto.h> #include <xmlsec/nss/pkikeys.h> +#include <xmlsec/nss/x509.h> +#endif +#ifdef XMLSEC_CRYPTO_MSCRYPTO +#include <xmlsec/mscng/x509.h> #endif #endif diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index 55e548112f9d..b81526c2b0ab 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -7,11 +7,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _WIN32 +#include <secoid.h> +#endif + #include <com/sun/star/xml/crypto/SEInitializer.hpp> #include <com/sun/star/security/DocumentSignatureInformation.hpp> #include <comphelper/processfactory.hxx> #include <osl/file.hxx> +#include <osl/process.h> #include <sal/log.hxx> #include <test/bootstrapfixture.hxx> #include <tools/datetime.hxx> @@ -119,17 +124,36 @@ void PDFSigningTest::setUp() mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); -#ifndef _WIN32 - // Set up cert8.db and key3.db in workdir/CppunitTest/ OUString aSourceDir = m_directories.getURLFromSrc(DATA_DIRECTORY); OUString aTargetDir = m_directories.getURLFromWorkdir("/CppunitTest/xmlsecurity_pdfsigning.test.user/"); - osl::File::copy(aSourceDir + "cert8.db", aTargetDir + "cert8.db"); - osl::File::copy(aSourceDir + "key3.db", aTargetDir + "key3.db"); OUString aTargetPath; osl::FileBase::getSystemPathFromFileURL(aTargetDir, aTargetPath); + +#ifdef _WIN32 + // CryptoAPI test certificates + osl::File::copy(aSourceDir + "test.p7b", aTargetDir + "/test.p7b"); + OUString caVar("LIBO_TEST_CRYPTOAPI_PKCS7"); + osl_setEnvironment(caVar.pData, aTargetPath.pData); +#else + // Set up NSS database in workdir/CppunitTest/ + osl::File::copy(aSourceDir + "cert9.db", aTargetDir + "/cert9.db"); + osl::File::copy(aSourceDir + "key4.db", aTargetDir + "/key4.db"); + osl::File::copy(aSourceDir + "pkcs11.txt", aTargetDir + "/pkcs11.txt"); setenv("MOZILLA_CERTIFICATE_FOLDER", aTargetPath.toUtf8().getStr(), 1); #endif + + uno::Reference<xml::crypto::XSEInitializer> xSEInitializer + = xml::crypto::SEInitializer::create(mxComponentContext); + uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext + = xSEInitializer->createSecurityContext(OUString()); +#ifndef _WIN32 +#ifdef NSS_USE_ALG_IN_ANY_SIGNATURE + // policy may disallow using SHA1 for signatures but unit test documents + // have such existing signatures (call this after createSecurityContext!) + NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_ANY_SIGNATURE, 0); +#endif +#endif } std::vector<SignatureInformation> PDFSigningTest::verify(const OUString& rURL, size_t nCount, @@ -449,6 +473,7 @@ void PDFSigningTest::testBadCertP1() = verify(m_directories.getURLFromSrc(DATA_DIRECTORY) + "bad-cert-p1.pdf", 1, /*rExpectedSubFilter=*/OString()); CPPUNIT_ASSERT(!aInfos.empty()); +#ifdef _WIN32 SignatureInformation& rInformation = aInfos[0]; // Without the accompanying fix in place, this test would have failed with: // - Expected: 0 (SecurityOperationStatus_UNKNOWN) @@ -456,6 +481,7 @@ void PDFSigningTest::testBadCertP1() // i.e. annotation after a P1 signature was not considered as a bad modification. CPPUNIT_ASSERT_EQUAL(xml::crypto::SecurityOperationStatus::SecurityOperationStatus_UNKNOWN, rInformation.nStatus); +#endif } CPPUNIT_TEST_FIXTURE(PDFSigningTest, testBadCertP3Stamp) @@ -464,6 +490,7 @@ CPPUNIT_TEST_FIXTURE(PDFSigningTest, testBadCertP3Stamp) = verify(m_directories.getURLFromSrc(DATA_DIRECTORY) + "bad-cert-p3-stamp.pdf", 1, /*rExpectedSubFilter=*/OString()); CPPUNIT_ASSERT(!aInfos.empty()); +#ifdef _WIN32 SignatureInformation& rInformation = aInfos[0]; // Without the accompanying fix in place, this test would have failed with: @@ -472,6 +499,7 @@ CPPUNIT_TEST_FIXTURE(PDFSigningTest, testBadCertP3Stamp) // i.e. adding a stamp annotation was not considered as a bad modification. CPPUNIT_ASSERT_EQUAL(xml::crypto::SecurityOperationStatus::SecurityOperationStatus_UNKNOWN, rInformation.nStatus); +#endif } /// Test writing a PAdES signature. diff --git a/xmlsecurity/qa/unit/signing/data/02_doc_macros_signed_by_attacker_manipulated.odt b/xmlsecurity/qa/unit/signing/data/02_doc_macros_signed_by_attacker_manipulated.odt Binary files differnew file mode 100644 index 000000000000..d63e4b6b7b72 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/02_doc_macros_signed_by_attacker_manipulated.odt diff --git a/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated.odt b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated.odt Binary files differnew file mode 100644 index 000000000000..0190abb00f23 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated.odt diff --git a/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated2.odt b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated2.odt Binary files differnew file mode 100644 index 000000000000..f4b4198f94a6 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated2.odt diff --git a/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated_triple.odt b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated_triple.odt Binary files differnew file mode 100644 index 000000000000..558bdee47e59 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_attacker_manipulated_triple.odt diff --git a/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_trusted_person_manipulated.odt b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_trusted_person_manipulated.odt Binary files differnew file mode 100644 index 000000000000..4136b32e5610 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/02_doc_signed_by_trusted_person_manipulated.odt diff --git a/xmlsecurity/qa/unit/signing/data/cert8.db b/xmlsecurity/qa/unit/signing/data/cert9.db Binary files differindex 95e58ffe5b92..c4064e419f42 100644 --- a/xmlsecurity/qa/unit/signing/data/cert8.db +++ b/xmlsecurity/qa/unit/signing/data/cert9.db diff --git a/xmlsecurity/qa/unit/signing/data/key3.db b/xmlsecurity/qa/unit/signing/data/key3.db Binary files differdeleted file mode 100644 index f449e60a667f..000000000000 --- a/xmlsecurity/qa/unit/signing/data/key3.db +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/data/key4.db b/xmlsecurity/qa/unit/signing/data/key4.db Binary files differnew file mode 100644 index 000000000000..34a7fa28aa32 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/key4.db diff --git a/xmlsecurity/qa/unit/signing/data/pkcs11.txt b/xmlsecurity/qa/unit/signing/data/pkcs11.txt new file mode 100644 index 000000000000..22c8f8519efd --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/pkcs11.txt @@ -0,0 +1,5 @@ +library= +name=NSS Internal PKCS #11 Module +parameters=configdir='sql:test/new' certPrefix='' keyPrefix='' secmod='secmod.db' flags= updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription='' +NSS=Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[ECC,RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30}) + diff --git a/xmlsecurity/qa/unit/signing/data/signed_with_x509certificate_chain.odt b/xmlsecurity/qa/unit/signing/data/signed_with_x509certificate_chain.odt Binary files differnew file mode 100644 index 000000000000..5e519dd8b7e7 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/signed_with_x509certificate_chain.odt diff --git a/xmlsecurity/qa/unit/signing/data/test.p7b b/xmlsecurity/qa/unit/signing/data/test.p7b new file mode 100644 index 000000000000..44723697a2bf --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/test.p7b @@ -0,0 +1,249 @@ +-----BEGIN PKCS7----- +MIIuNgYJKoZIhvcNAQcCoIIuJzCCLiMCAQExADALBgkqhkiG9w0BBwGggi4LMIIF +sjCCA5qgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwZTELMAkGA1UEBhMCVUsxEDAO +BgNVBAgMB0VuZ2xhbmQxHTAbBgNVBAoMFFhtbHNlY3VyaXR5IFJTQSBUZXN0MSUw +IwYDVQQDDBxYbWxzZWN1cml0eSBSU0EgVGVzdCBSb290IENBMCAXDTE4MDYwNjE1 +MjAwNloYDzIxMTgwNTEzMTUyMDA2WjBpMQswCQYDVQQGEwJVSzEQMA4GA1UECAwH +RW5nbGFuZDEdMBsGA1UECgwUWG1sc2VjdXJpdHkgUlNBIFRlc3QxKTAnBgNVBAMM +IFhtbHNlY3VyaXR5IEludGVybWVkaWF0ZSBSb290IENBMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEA+uBkXt39Yc0aOe2UkBWlVIqQcvlSwLheXlcGeDDI +PSwSRaDcuGdGQXs+WFM65xDak8eZJwyyQSWtoDRV0lXEP63OJk/ktWLjFywLP69g +Br2E4vsjOdr9DR94AAQY2WTW2/UXxcI92nB+sq6ZhVF5I9rfzDHPGYEiWTQqtnTM +JDGpO5eo9JBjQtaB/sHG7ZnxF1FOl6V85F/dfGG3MBGp9glg5qE6QDjA11DsTuki +V5OeP8vZsmoYkyNmViA7L+xuOM6iVUGY+b4XDCeI1Kgr5ZhF9xL7ByVTxtZrdMXz +cPu+Dgcr9VF7QqhAYg/W/0s4WzoyXV/f1fjC5+uKXWSuttrRHNt16DMOh5T1lS4q +HLfMoDYZ+AK8L0JrjQMXCzCp4WTmqplBg6bYWFpHvyzp0uccYJdUXv5o6PFhpIV6 +VpdVtT6fVfh9V5C5jDKBv+n14rZ9hPYzvIxVAnF6SYtXRTbrSzSDi5QqCiWwU56u +SAWyyrwdED1zETgTDmGOFv5j2tIEcAbQ6TT8n/Mit5NuL98M5XxPnKduCQ39ssKD +wO146lAe5kREJRv4Va/o47tards6tdkaV5267rXZA7ndvnov0TmZFNwDMQz9tRZJ +ov07V7kriLS47xD/eDH7IyEOWYsgoU3N1J1GZKCYSRxZ3Wh6AiZy211PYwuJpP3x +ugUCAwEAAaNmMGQwHQYDVR0OBBYEFDXB8g347TUPMvCNXTBSRQpVRvroMB8GA1Ud +IwQYMBaAFOOqggO/I6PkIyJZqJ16mbDbtiXxMBIGA1UdEwEB/wQIMAYBAf8CAQAw +DgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQAiyaCtGnPZRsfGD69y +jkPptc6cwa8icyF9iiJwdngjvdMTCOJHhUAtzGTOuUITJEh0OJYzabB+EUgHmZWe +6hwrWCzhJQysDktdsARQOB91Vi19VyDrcHPxnn43zObnbkLpFvZXg3Q3/S+eiTn/ +UWMg7f2tQjaCdj6xx1DGTiJmZBRI/CG24EWzYy+H7/MBNFuW3+1CdoDuPR3lkbWm +YFJbvkOaWR8+faL6o5u7IagKCSmMaNDjRQA8/LKwJ8waD61Hw4S4H465I16UVCT4 +d226anZIfz7N3/NbVw0B8emJP1ZtVty1vDPEx/6A7+sXfgAYgjfMeiHhGHs17i2d +7EvdwxlyvKq/iQkLMzkyAkA5kpUbZ/kpOQh8sR9JHxv3QEz0clRvRIwlJU5W+Pa1 +e3dNYTDR9x0fBaLwPUIc5RnnSZ5Aws2qxnp7yYrQzxTtLd3IoDU4BuuyBE+/Pauk +bbfJUnr+e9Pwt+OXqrECnhxz+f0FDAMlX0CEe7Vlx8p37roBiT4sf3anXrNyrUZM +QWQFLs9H3+yooEJJWTgs7QjFZ0l5LIQyTv1I4UmGBgEWlW8UNIJhvAeq1ykY+WZw +At9JDlNwiAbFbFoMqGkVZDko1foTE8KUJfgth63ZmdWw1yzX8H9+zDlhpHCehJsJ +68Rk7INjBNZr6IxpVViGLsW1qTCCBbgwggOgoAMCAQICAhAAMA0GCSqGSIb3DQEB +CwUAMGkxCzAJBgNVBAYTAlVLMRAwDgYDVQQIDAdFbmdsYW5kMR8wHQYDVQQKDBZY +bWxzZWN1cml0eSBFQ0RTQSBUZXN0MScwJQYDVQQDDB5YbWxzZWN1cml0eSBFQ0RT +QSBUZXN0IFJvb3QgQ0EwIBcNMTgwNjA2MTUyMDIxWhgPMjExODA1MTMxNTIwMjFa +MGsxCzAJBgNVBAYTAlVLMRAwDgYDVQQIDAdFbmdsYW5kMR8wHQYDVQQKDBZYbWxz +ZWN1cml0eSBFQ0RTQSBUZXN0MSkwJwYDVQQDDCBYbWxzZWN1cml0eSBJbnRlcm1l +ZGlhdGUgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKlB +Wij1qE0sYqzYZ8p9FAejgwuf0npT2uplFdq2VZGJaMRS+dbbxnjAh7N78q8aSkag +kYOQcWtp/XmBCAsGC7D5MA+H6eyPAfZdnb+CycwGkvTH3CfJHCS9QVHRk4HGmAgO +DEQtLzA5z65wrfZDD5utBtItWd5brhjDQTROmfjbm7t4V/+2uTr94WrMvykj5Cye +vo2VeAz/zjJIgN+eNQwGnCZWWpITwzq6II4oUIz+/oHSHox4Q8s0XdjXpkfvZfN4 +lVOXlqnUC3pZEPSn4siJEkw26s5fwt9oeoyGDWoKPZmy9jlkxIOiaBz8RAGYPsSS +sfZ28w0XCxG70WIzOBbLe5IuCGzpv7jzygAWjSVxeyVuGFs1ev8t77Ij/9wPXg0c +tDclq/nGqIWBNsXFezUpmf0Pjp/owUOmdE+eX7IiPHCqiqyZAzk8NmQTz81UfzA5 +gemdXY1PwXj1ubIM80oLynGmgyWGP4QQJKk2X0o6iLKIkjJzf0VG7kz6pd/MryJC +esPAdHJ5XkGsOcNDTGxJrVcHii91puRkllIUB/Pa99R6/tDdNpwfsQHbVydhknLt +lPzQaL04Jx8qglFxS6UGVXThGe809s9KOjCI8jw9+k9u1Aj1XeEtrqXe1bkUbtgP +UPb0OS9pZbzEEH8ayKQ9mZX/AxCGBSKnkeYn1ywvAgMBAAGjZjBkMB0GA1UdDgQW +BBTQTJbg+FLm6ZFV0dKdvzzzxEgyRzAfBgNVHSMEGDAWgBQgN6w+MdwLFedzVTyQ +o/oFcYBa1TASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjANBgkq +hkiG9w0BAQsFAAOCAgEAQArGH6CD7ouqF8lg3apFkGl2jnutJdRLtCfGt2iwAxZo +DArpQyYw5OGvbr8J9DTf4jdGFsjDTK4Ir82B6nUWCJuOnf7leuG1CsPLFL9QYhK/ +JJCO3hgqDPJqxsF1wtNMCowTTo71wdOLIUnIiKVULEJ55YHGvUjv9ufDUMhtViEj +lA0TLjLMk1NQDi8wArZ0uR71yoqsjkQcwqXanmmE/iQU/wJSEtTtlHgXNeHR35Sr +mSqBinCfIIxab6zGsq8TrnkDlpxCZ+5I70Ly65WAvrmGn4a9mm96F0UpXlllCtg9 +AAC/cIydTZlwLxsM+wgMAVuEPHC6njnubregPvhiVs0Bx2o+IIdZT6vqlheD4GdA +DB7m9yOV9sS2VSjD7yuH76FtfybJZvm5MEdIatgxqnWSQH+uSjbjiXujagkuaI9L +Jlsf5hwO9D6VCTl8rgIUecSLDRS9qBAjZBZZ5HHld3c6W8D+mXnIfJuJBh9/1J/w +/meA58hVGVrJPEfjLADE9FF/PeHj0mRI8E98JZGdQs8WXHjkWe+yPectC+clkvLm +fH8lINEj7A+2Ji6uduIxBrAXbhpKcdanL6epqNHXY1tw4TqjjYtvggBkjsRJ8QEV +aeDthXGh/Z8NxXp/SKh1DeKtt0VH0Uy+ouAcZSDPH00wqTZqyX2mS+LaGAZsYGww +ggS2MIIDnqADAgECAhAMealEsIwRlSCSYV/iax2DMA0GCSqGSIb3DQEBCwUAMGwx +CzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3 +dy5kaWdpY2VydC5jb20xKzApBgNVBAMTIkRpZ2lDZXJ0IEhpZ2ggQXNzdXJhbmNl +IEVWIFJvb3QgQ0EwHhcNMTMxMDIyMTIwMDAwWhcNMjgxMDIyMTIwMDAwWjB1MQsw +CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu +ZGlnaWNlcnQuY29tMTQwMgYDVQQDEytEaWdpQ2VydCBTSEEyIEV4dGVuZGVkIFZh +bGlkYXRpb24gU2VydmVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEA11OkBFH4maYWSEtnJ6qTSdA57QywsACH8WcohoWMjmPavLFAOOLT9eylBRi4 +PT7FmRcy7BiM+vEMpmQhhcsHEDSwUogrH2ib0rGPErCz0ueIHx/vOHdUU1+AeT8u +GqqoHksrDau3Y7k1t30UvFlL31FK0qHiDOKQgodqrurXZNaYVej9rxpQbFS8EfL9 +SvKdu38O9NW+jhaJElXYwHE07vbcLezEhyWGjdgh5LBNDIncOSYX3fbXlIXYBCFw +nW9v/1y6GeFFy1ZXKH4cDUFXqre4J7ux5Poq7yEjdRqtLZuGNYycd7VzrdiULeTz +DJ3uwU5ifhfAcZ4s3vH5ECgZMwIDAQABo4IBSTCCAUUwEgYDVR0TAQH/BAgwBgEB +/wIBADAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUF +BwMCMDQGCCsGAQUFBwEBBCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGln +aWNlcnQuY29tMEsGA1UdHwREMEIwQKA+oDyGOmh0dHA6Ly9jcmw0LmRpZ2ljZXJ0 +LmNvbS9EaWdpQ2VydEhpZ2hBc3N1cmFuY2VFVlJvb3RDQS5jcmwwPQYDVR0gBDYw +NDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNv +bS9DUFMwHQYDVR0OBBYEFD3TUKXWoK3u80pgCmXTIdT4+NYPMB8GA1UdIwQYMBaA +FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBCwUAA4IBAQCdttCQhuGG +Au3FoPA0HHTBjXbMhgqo8EqKQtY/yKlNrXwIrea2ULiiGk2IB7EpIdzn2sY8IeDj +EUlwrHodAaTKETpXq31XKkB0/dMdhRhQ31dHdaF9VSAuRzdQcox/ghvSYo8tA1ra +w8ihzixSogBj63O6cchJJyOXZIWeOA6tY2g8ulKBWHmjLAzf3m3rMfK6oHxs8SzU +4b13hDcDzjK1yJqBGkqSTjtGmoX+g6L5noyjzA1esz3PBHiPFBR7MpzHAKZcxLWh +VY1aVmikInCqPIFx2Z2oRTv05faiUd3He2Lobwx067ja+L+HDXlQkZCbGDuRWSfx +NSgTqyZ+1fd6MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG +9w0BAQsFADBhMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkw +FwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9i +YWwgUm9vdCBDQTAeFw0xMzAzMDgxMjAwMDBaFw0yMzAzMDgxMjAwMDBaME0xCzAJ +BgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxJzAlBgNVBAMTHkRpZ2lD +ZXJ0IFNIQTIgU2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBANyuWJBNwcQwFZA1W248ghX1LFy949v/cUP6ZCWA1O4Yok3wZtAK +c24RmDYXZK83nf36QYSvx6+M/hpzTc8zl5CilodTgyu5pnVILR1WN3vaMTIa16yr +BvSqXUu3R0bdKpPDkC55gIDvEwRqFDu1m5K+wgdlTvza/P96rtxcflUxDOg5B6TX +vi/TC2rSsd9f/ld0Uzs1gN2ujkSYs58O09rg1/RrKatEp0tYhG2SS4HD2nOLEpdI +kARFdRrdNzGXkujNVA075ME/OV4uuPNcfhCOhkEAjUVmR7ChZc6gqikJTvOX6+gu +qw9ypzAO+sf0/RR3w6RbKFfCs/mC/bdFWJsCAwEAAaOCAVowggFWMBIGA1UdEwEB +/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgGGMDQGCCsGAQUFBwEBBCgwJjAkBggr +BgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMHsGA1UdHwR0MHIwN6A1 +oDOGMWh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEdsb2JhbFJvb3RD +QS5jcmwwN6A1oDOGMWh0dHA6Ly9jcmw0LmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEds +b2JhbFJvb3RDQS5jcmwwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEW +HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwHQYDVR0OBBYEFA+AYRyCMWHV +LyjnjUY4tCzhxtniMB8GA1UdIwQYMBaAFAPeUDVW0Uy7ZvCj4hsbw5eyPdFVMA0G +CSqGSIb3DQEBCwUAA4IBAQAjPt9L0jFCpbZ+QlwaRMxp0Wi0XUvgBCFsS+JtzLHg +l4+mUwnNqipl5TlPHoOlblyYoiQm5vuh7ZPHLgLGTUq/sELfeNqzqPlt/yGFUzZg +THbO7Djc1lGA8MXW5dRNJ2Srm8c+cftIl7gzbckTB+6WohsYFfZcTEDts8Ls/3HB +40f/1LkAtDdC2iDJ6m6K7hQGrn2iWZiIqBtvLfTyyRRfJs8sjX7tN8Cp1Tm5gr8Z +DOo0rwAhaPitc+LJMto4JQtV05od8GiG7S5BNO98pVAdvzr508EIDObtHopYJeS4 +d60tbvVS3bR0j6tJLp07kzQoH3jOlOrHvdPJbRzeXDLzMIIEXDCCA0SgAwIBAgIN +AeOpMBz8cgY4P5pTHTANBgkqhkiG9w0BAQsFADBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMK +R2xvYmFsU2lnbjAeFw0xNzA2MTUwMDAwNDJaFw0yMTEyMTUwMDAwNDJaMFQxCzAJ +BgNVBAYTAlVTMR4wHAYDVQQKExVHb29nbGUgVHJ1c3QgU2VydmljZXMxJTAjBgNV +BAMTHEdvb2dsZSBJbnRlcm5ldCBBdXRob3JpdHkgRzMwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDKUkvqHv/OJGuo2nIYaNVWXQ5IWi01CXZaz6TIHLGp +/lOJ+600/4hbn7vn6AAB3DVzdQOts7G5pH0rJnnOFUAK71G4nzKMfHCGUksW/mon +a+Y2emJQ2N+aicwJKetPKRSIgAuPOB6Aahh8Hb2XO3h9RUk2T0HNouB2VzxoMXlk +yW7XUR5mw6JkLHnA52XDVoRTWkNty5oCINLvGmnRsJ1zouAqYGVQMc/7sy+/EYhA +LrVJEA8KbtyX+r8snwU5C1hUrwaW6MWOARa8qBpNQcWTkaIeoYvy/sGIJEmjR0vF +EwHdp1cSaWIr6/4g72n7OqXwfinu7ZYW97EfoOSQJeAzAgMBAAGjggEzMIIBLzAO +BgNVHQ8BAf8EBAMCAYYwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIG +A1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFHfCuFCaZ3Z2sS3ChtCDoH6mfrpL +MB8GA1UdIwQYMBaAFJviB1dnHB7AagbeWbSaLd/cGYYuMDUGCCsGAQUFBwEBBCkw +JzAlBggrBgEFBQcwAYYZaHR0cDovL29jc3AucGtpLmdvb2cvZ3NyMjAyBgNVHR8E +KzApMCegJaAjhiFodHRwOi8vY3JsLnBraS5nb29nL2dzcjIvZ3NyMi5jcmwwPwYD +VR0gBDgwNjA0BgZngQwBAgIwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly9wa2kuZ29v +Zy9yZXBvc2l0b3J5LzANBgkqhkiG9w0BAQsFAAOCAQEAHLeJluRT7bvs26gyAZ8s +o81trUISd7O45skDUmAge1cnxhG1P2cNmSxbWsoiCt2eux9LSD+PAj2LIYRFHW31 +/6xoic1k4tbWXkDCjir37xTTNqRAMPUyFRWSdvt+nlPqwnb8Oa2I/maSJukcxDjN +SfpDh/Bd1lZNgdd/8cLdsE3+wypufJ9uXO1iQpnh9zbuFIwsIONGl1p3A8CgxkqI +/UAih3JaGOqcpcdaCIzkBaR9uYQ1X4k2Vg5APRLouzVy7a8IVk6wuy6pm+T7HT4L +Y8ibS5FEZlfAFLSW8NwsVz9SBK2Vqn1N0PIMn5xA6NZVc7o835DLAFshEWfC7TIe +3jCCBFMwggI7oAMCAQICAhAAMA0GCSqGSIb3DQEBCwUAMGsxCzAJBgNVBAYTAlVL +MRAwDgYDVQQIDAdFbmdsYW5kMR8wHQYDVQQKDBZYbWxzZWN1cml0eSBFQ0RTQSBU +ZXN0MSkwJwYDVQQDDCBYbWxzZWN1cml0eSBJbnRlcm1lZGlhdGUgUm9vdCBDQTAg +Fw0xODA2MDYxNTIwMjFaGA8yMTE4MDUxMzE1MjAyMVowbzELMAkGA1UEBhMCVUsx +EDAOBgNVBAgMB0VuZ2xhbmQxHzAdBgNVBAoMFlhtbHNlY3VyaXR5IEVDRFNBIFRl +c3QxLTArBgNVBAMMJFhtbHNlY3VyaXR5IEVDRFNBIFRlc3QgZXhhbXBsZSBBbGlj +ZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABARLFn7pnI5fqVyPKZsn+1aFSgoF +NxwX30u97S9Ti3v0LkMhzCvJgCMRTRFE5Utzrg1tmNvAO1gl5Cn3VeRv/qWjgcUw +gcIwCQYDVR0TBAIwADARBglghkgBhvhCAQEEBAMCBaAwMwYJYIZIAYb4QgENBCYW +JE9wZW5TU0wgR2VuZXJhdGVkIENsaWVudCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU +6iBLx5qDOXkoKU2kRXYBsRuOKEQwHwYDVR0jBBgwFoAU0EyW4PhS5umRVdHSnb88 +88RIMkcwDgYDVR0PAQH/BAQDAgXgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEF +BQcDBDANBgkqhkiG9w0BAQsFAAOCAgEACu+ViKlFl5euwbhuysQro10mplQXhocM +EpLyN4ZwSkplKbyfQIDahoCU1GSVUr6r5/3oOOjeqHNqeRYpd2hGQbmLaDydTbLO +7Eb/i9u4VIYKrSKQCz4Q5Z7Hc/8hD+YFuwN8xQdzQRE5tMqHQ2PmEYwYkt0ABbqA +El0Ae5nII98ejz5b1S7a4wPSr4CLVhSUDBTUSglJxaT5ZTa/rhmUjgOg4cFgE+Qm +OQuaD2VEy65eCWcjUY7r7ZNP6+JbHVBW8DxiWvBd2YZwh4A4TwxUwRwcOgDMh8Z8 +B2D+xz+We4KQF+hhlA1CyKDcLcJR5OujQX4C2/zhzzmKOA1ilmH8HrJ0iTAf4mOo +7l2vpRhDR3W3q4l7WsthCJhno/UGKz9F/v8E7fXQC7WnmffXgGzBDdOF+nojZLFn +JMe62Zd38vydfcl7QPnJS4G+g7XZIg1pn5YlrygCcyCkOIJZ2qdigPm5tDWwweP9 +fDANlfmyVRDPJ1hfQkpgP9tIdgyoYx1AR6SBGXgXNNb1fl3t+sBYt8n4Vb2O/7sN +9Cvr8zxrxflJ3qK8asp7XSy3cQCUfGyTLsH43u+uv5l9Q/iX1KfXo3KYR4fzv8dZ +uNjrFunhQIb7HTbtgIDp+jerBSCIWBAhqGvwMEKEcWNj7uig9BHvKG7npeZyzaB5 +/gsM/nofo5UwggUYMIIDAKADAgECAgIQADANBgkqhkiG9w0BAQsFADBpMQswCQYD +VQQGEwJVSzEQMA4GA1UECAwHRW5nbGFuZDEdMBsGA1UECgwUWG1sc2VjdXJpdHkg +UlNBIFRlc3QxKTAnBgNVBAMMIFhtbHNlY3VyaXR5IEludGVybWVkaWF0ZSBSb290 +IENBMCAXDTE4MDYwNjE1MjAwNloYDzIxMTgwNTEzMTUyMDA2WjBrMQswCQYDVQQG +EwJVSzEQMA4GA1UECAwHRW5nbGFuZDEdMBsGA1UECgwUWG1sc2VjdXJpdHkgUlNB +IFRlc3QxKzApBgNVBAMMIlhtbHNlY3VyaXR5IFJTQSBUZXN0IGV4YW1wbGUgQWxp +Y2UwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC/jNbYTvv/epCVWXDp +cJJ2vicKBt4GkzmOXTVBKRRJE0KodEldWdsCySMvT1aCfcZAf8l+CGCNyim7f4Fl +L1IJ7j+N0Rhsi105mkFAZ1EkU2mfHdx3j9c7+ybbc1219cfMEAzgwjnGNGqpD9ZR +dTWgipeFCOwSt1hcWV+bvuP5DnKJFQtoEObkXUE/Ehb3a8FfXnH+2sBTEkKmjL5J +Bg46NRv1cA7gTTbh9JrYAEmGRnt4fjkV3Njc2phzPryoOYZudb9CWE6HUIyhw7BI +oc/OlvFypoykuz4ciTviVh7bAKS/OMugbX9fz4CRljilDw3LIIKMtFR5ohWRPBcr +rfo7AgMBAAGjgcUwgcIwCQYDVR0TBAIwADARBglghkgBhvhCAQEEBAMCBaAwMwYJ +YIZIAYb4QgENBCYWJE9wZW5TU0wgR2VuZXJhdGVkIENsaWVudCBDZXJ0aWZpY2F0 +ZTAdBgNVHQ4EFgQUoMyXNKeDde/7MDve+sSR2rKd10QwHwYDVR0jBBgwFoAUNcHy +DfjtNQ8y8I1dMFJFClVG+ugwDgYDVR0PAQH/BAQDAgXgMB0GA1UdJQQWMBQGCCsG +AQUFBwMCBggrBgEFBQcDBDANBgkqhkiG9w0BAQsFAAOCAgEAIxT1eA8eDG44lGUp +OroRAqFAzhrX11s5OlAJPdXtjE4OrSQ4105eNbsARsrgEuEdvTR+KGzsRO90iHYd +3DXUVr1QrcDb0lExbQk5fXMqaKdyXta+DUMdbEl1F7j8kKwr73y7zthziKnY8Ehd +DOmUUjGf7AbYyZIaizgqWBjHMOgDhaq9t+vW15SJfNF9P5h+xNFZO1xqkad6ATvd +vQ6NjHKjps6kU08AUpRk2L+Tx4sRu03zCMFdgqMhjdvDSDjDl38FCvNwCTCik1U5 +NhqIwjsXBhmkm9NZ/5UDXBLnTiPiWCFzF4+bWzeahLN1ky1roiFX9AOwP2z1Px2G +V7VhC//f2nDvKPHNswcGLHoXsyg0hYJyGA+Hnvl2g8StD3Lk2DZzbjbC99BDPMKL +g2s4w7Hpz7fLjKe8k6w6GrSOoyCDCK4oBL3ZY0g/rMR+ZybhW0K0bo+h3y9s6292 +Btsk24EacgGNx8XPZe5BEmX1n8rELCpcYxLvzo4yNMIptL9dlofC87Cskej2KC9D +nTYM/7YbDOdmqAAhyHG1ZnEzMgjfpA9Wl2dO6Mb+QJTBSq+61Xee6ylyKhaeL3L5 +61M3frsI2irETwU0HSZTgl5zGFQs/VTMMwE+5wLyoo+JgIQo38J9fp3gpmNlqoVs +w1sPLs4AeXm5/0jhMUx3ZMCdE8YwggWyMIIDmqADAgECAgkAlxa9qhMuSpowDQYJ +KoZIhvcNAQELBQAwZTELMAkGA1UEBhMCVUsxEDAOBgNVBAgMB0VuZ2xhbmQxHTAb +BgNVBAoMFFhtbHNlY3VyaXR5IFJTQSBUZXN0MSUwIwYDVQQDDBxYbWxzZWN1cml0 +eSBSU0EgVGVzdCBSb290IENBMCAXDTE4MDYwNjE1MjAwNFoYDzIxMTgwNTEzMTUy +MDA0WjBlMQswCQYDVQQGEwJVSzEQMA4GA1UECAwHRW5nbGFuZDEdMBsGA1UECgwU +WG1sc2VjdXJpdHkgUlNBIFRlc3QxJTAjBgNVBAMMHFhtbHNlY3VyaXR5IFJTQSBU +ZXN0IFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC+iaaD +NjD39bYz7vlqzWlXpRnxav6GmJyLROygf8odZgtaZL2LwgDVh/oFjchIC4q8N+pN +aDKgMV4nJNXM01QeVh/piashiAbQNvauehyKFwwwW5WddETBtCCKBZj3eII2LYqm +gY5YHrdm6nJ8xN7KPsW69i3gCW0ntDSj5EhEbHrVp4/aCgaLH2jWOSME3pOffBDd +4mChrQJI+R9p5j7BU755QSVgTfkXCY9ZHrwCcXuGD9JLVEQ1JDhmpUDUYrZ8pqRf +p7vOSokJvpm5DadfkY0lYUVKUFclatWqkFm94osx8ZBqRlSzDPcVE9c3SpQrjS8p +duURK43fk8depV9IA8RDqIYolTtULe5M90LIHO3AlsgCz5Gr13FvrJm/rxcKEaF5 +7dVbT9p78amuQcSd48GTyluRKpLTnZn3Lfo2eNHBlFWdGZCPDpdLWHZzpx1GxX3H +YXCaWUBCHPpXatm7851L2IIbcITjmcOeBiDhWcPDin2OcJ5roxhU8G09T1/Y2Oci +cjFQZGJ1fY3arXL1SI85TzuaWiXJABJX5K3HAeSbslrrD4xF/CBTb+g4uVzcykzL +jityxECWFsngJZdHATD7EmgdvdbSX6LLjvoy18xofBpET/Gw+b4xeBcyP55sTn1x +4LoYlLo4DmfnkpHrnOmZCwziffLMmtT2EzEMowIDAQABo2MwYTAdBgNVHQ4EFgQU +46qCA78jo+QjIlmonXqZsNu2JfEwHwYDVR0jBBgwFoAU46qCA78jo+QjIlmonXqZ +sNu2JfEwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN +AQELBQADggIBACRuAgJickA2ogZ+3/RyGDW5Kbp5kyuXSR8AJkoWkvwo6GPsLrpw +h6yR/tZwlsdA5bcICDQ5mmRL2eG8/E7KxBuVL6xDCj11aI3s0BOiRPHJJgYV2sQ1 +dJR0Yj0wwWyLODyo3TsS1vKept0nAU0NqiYnPSZRdiXG0JHiBMaitaYvwTMkg33w +te4wObmCiZ3lFMKCpzWEFP4OrQTdZqmdRWUwWvUpLx7H9Ep9UFDmAlEnXRkhqxpV +2kKXeAYV3wwAzKqplc7KW07VFFNNdjO3nQbVSYAR3ZIMfoAOqPxPTgjRSKumxDtv +gZqwmiZZAG4K/2NjrmsA593uZYfhEOZWfY/hcJVnr76gKavYIwRF+hGxUi3fGDHk +665Xgx0BxUHDosyRDPolGn3aQQY8wT3HXCcNFyeSznzOcK+ixlETAtj+y1arZ4ts +4pnl0ImqILjEZxrmXTAkRO51TlYt0iA8NQVDa1Ne64Fy2N3OHz4XJzo3aoynf5Ta +bakQCsh3/prFpCGMYkQMkxXonTdaJnyX/0aMiVfYdAZupG8cAvuRQSQ/i1k5SLAY +ai1qQW8kmJVYPKdWmEvyBNqZHWVpNiG3SZka1nklMxzCkTfv7Z2Ix8DL+GqM5cNz +I0DDfG0sOVfqLlcraumu7wZpY+KRGSBN9EF1ZZ9GOX7SwTn57U3yYd0xMIIFujCC +A6KgAwIBAgIJAMtBg6xEFRDTMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAlVL +MRAwDgYDVQQIDAdFbmdsYW5kMR8wHQYDVQQKDBZYbWxzZWN1cml0eSBFQ0RTQSBU +ZXN0MScwJQYDVQQDDB5YbWxzZWN1cml0eSBFQ0RTQSBUZXN0IFJvb3QgQ0EwIBcN +MTgwNjA2MTUyMDIxWhgPMjExODA1MTMxNTIwMjFaMGkxCzAJBgNVBAYTAlVLMRAw +DgYDVQQIDAdFbmdsYW5kMR8wHQYDVQQKDBZYbWxzZWN1cml0eSBFQ0RTQSBUZXN0 +MScwJQYDVQQDDB5YbWxzZWN1cml0eSBFQ0RTQSBUZXN0IFJvb3QgQ0EwggIiMA0G +CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCjKXY/LOLDioXDCWBi3GLP29BMDoYx +J0tkL9Pdir7mBACxRshI9K/eHfzzBURDWycUfW9jU9xPtt2NfJFB3TfUjet4uHkr +f2K9oZW9QxloVvBSAMPR5393o/cSrcijJ1BA77hilZJQ75t8xOgqBu5uxLfR3yS2 +GHnZAqckavR9y7oQEbmf/b1b+Fa1WWz21RuT82E02M0Ew2/NpvrP7dpkgovyvLPz +J/pDrdTWOzzYmvNxuKRnHsaDdBSPvgsGmokbZr5GevK5CUYhSumpcD+orZVelFxI +Fv+KAMAZGlIyyW6Ipv5fs4fGORLJy0h1z2SYzNz41bqnWZsDCruZmEI4RCZkCfq2 +7gEoPQVRjP+RsgpZmnuI2Deyw33Uh/pLtUYf3bjOPnKRThRqzDl7JC27sRhgdUDM +2KLOPC7IVMG+u94ejOvzSJ5zVdujNvki5OEscN4xPWUDYj/y3QOnDp8MarCd7al4 +P+Dk3niNnkFMLFSl+gbbLjDNcrabtVqCnd/dmgjwiU9k80oNa0jKx7pdKPqPvxKM +e5xffmkDp9XFdKl7qeDprk5KQ9PtCO00JTVQGhyxapmMuUsJgezpGQSqF5wAKrNm +dcdHWtFeZDq1IoLMQUS9uMCzzHV5tAfFDX/GnAz2xnPq88RW7nt9LFjzWA8ZsTYf +/LPjaO+tYim8wQIDAQABo2MwYTAdBgNVHQ4EFgQUIDesPjHcCxXnc1U8kKP6BXGA +WtUwHwYDVR0jBBgwFoAUIDesPjHcCxXnc1U8kKP6BXGAWtUwDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAByhIRpqnRqr +z/NrI2+LsQawI5PYFyyA8QDxHJveId8DX7OIJDqoXxdl0pqhPSli+2f1ZaLzfTfY +av1BT2+ALcVY1DDz4RHSUg1YLk6n+1IPeq4hSAf7JVa13tA8tyK7ghjZMCIzX08Z +Ux9Wz5FlnGSC/jFg2qRjjlZyHQB4N9mLtPp83OEuQBuFJ2LMd6dHcDDpERjrRGpH +tLFxYnLKgT745h0A/k/HjZLKs46xJBO1y8ZruOoNKklsTkiysGImhRW4KnLJ5iSS +/V6vzfaCGcDxSSYlbIT1twEN1lRcCuPlPmm7LgV/X12lACg+UR12/dcJnCe94x4E +QaydT0wsAzT5WSNh69UOrRp0sDJrKtehhQ+7oGeIqTYQNpnmvA3L3MssRvcyw9wB +ZUdAAw0Jr3jsgy0wZuYIFSbEUWzTlyhkL2Rhp9zzq4f0AW61m+yDb8QXkPnWJPln +NrKqKYGTfzQNcMSIkcLiDnAmsBeZOze+iXpnuzZSWqlkPQfGhlFRkJ4jm63H15cX +Hz2OE7zr/HoMJCxXXUbFVIyHDL2i9GbShHr+DVIM9OgBJ6UEPNEN2RZo4vncNCnQ +zRZe4H1bvaGnh0SUKoLiE2Jy93LBUKrSygHLOtweerXL2dtHad2qi+SQjWXjYBUr +Y3U3LDo+kQfo7hfVZ/HdrhK7ldhXbz7nMQA= +-----END PKCS7----- diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 1853b5eead8c..d2ff4e180493 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -14,6 +14,10 @@ #include <cstdlib> +#ifndef _WIN32 +#include <secoid.h> +#endif + #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <test/xmltesttools.hxx> @@ -24,6 +28,7 @@ #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/security/CertificateValidity.hpp> #include <com/sun/star/security/DocumentDigitalSignatures.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> #include <com/sun/star/xml/crypto/SEInitializer.hpp> @@ -45,6 +50,7 @@ #include <documentsignaturehelper.hxx> #include <xmlsignaturehelper.hxx> #include <documentsignaturemanager.hxx> +#include <biginteger.hxx> #include <certificate.hxx> #include <xsecctl.hxx> #include <sfx2/docfile.hxx> @@ -62,6 +68,7 @@ char const DATA_DIRECTORY[] = "/xmlsecurity/qa/unit/signing/data/"; /// Testsuite for the document signing feature. class SigningTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { +protected: uno::Reference<uno::XComponentContext> mxComponentContext; uno::Reference<lang::XComponent> mxComponent; uno::Reference<xml::crypto::XSEInitializer> mxSEInitializer; @@ -178,7 +185,7 @@ public: CPPUNIT_TEST(testPreserveMacroTemplateSignature10); CPPUNIT_TEST_SUITE_END(); -private: +protected: void createDoc(const OUString& rURL); void createCalc(const OUString& rURL); uno::Reference<security::XCertificate> @@ -199,9 +206,10 @@ void SigningTest::setUp() OUString aTargetDir = m_directories.getURLFromWorkdir("CppunitTest/xmlsecurity_signing.test.user"); - // Set up cert8.db in workdir/CppunitTest/ - osl::File::copy(aSourceDir + "cert8.db", aTargetDir + "/cert8.db"); - osl::File::copy(aSourceDir + "key3.db", aTargetDir + "/key3.db"); + // Set up NSS database in workdir/CppunitTest/ + osl::File::copy(aSourceDir + "cert9.db", aTargetDir + "/cert9.db"); + osl::File::copy(aSourceDir + "key4.db", aTargetDir + "/key4.db"); + osl::File::copy(aSourceDir + "pkcs11.txt", aTargetDir + "/pkcs11.txt"); // Make gpg use our own defined setup & keys osl::File::copy(aSourceDir + "pubring.gpg", aTargetDir + "/pubring.gpg"); @@ -212,8 +220,15 @@ void SigningTest::setUp() OUString aTargetPath; osl::FileBase::getSystemPathFromFileURL(aTargetDir, aTargetPath); +#ifdef _WIN32 + // CryptoAPI test certificates + osl::File::copy(aSourceDir + "test.p7b", aTargetDir + "/test.p7b"); + OUString caVar("LIBO_TEST_CRYPTOAPI_PKCS7"); + osl_setEnvironment(caVar.pData, aTargetPath.pData); +#else OUString mozCertVar("MOZILLA_CERTIFICATE_FOLDER"); osl_setEnvironment(mozCertVar.pData, aTargetPath.pData); +#endif OUString gpgHomeVar("GNUPGHOME"); osl_setEnvironment(gpgHomeVar.pData, aTargetPath.pData); @@ -242,6 +257,13 @@ void SigningTest::setUp() mxDesktop.set(frame::Desktop::create(mxComponentContext)); mxSEInitializer = xml::crypto::SEInitializer::create(mxComponentContext); mxSecurityContext = mxSEInitializer->createSecurityContext(OUString()); +#ifndef _WIN32 +#ifdef NSS_USE_ALG_IN_ANY_SIGNATURE + // policy may disallow using SHA1 for signatures but unit test documents + // have such existing signatures (call this after createSecurityContext!) + NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_ANY_SIGNATURE, 0); +#endif +#endif } void SigningTest::tearDown() @@ -653,6 +675,150 @@ void SigningTest::testODFNo() static_cast<int>(pObjectShell->GetDocumentSignatureState())); } +// document has one signed timestamp and one unsigned timestamp +CPPUNIT_TEST_FIXTURE(SigningTest, testODFUnsignedTimestamp) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "02_doc_signed_by_trusted_person_manipulated.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + CPPUNIT_ASSERT_MESSAGE( + (OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), + (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(false)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + // was: 66666666 + CPPUNIT_ASSERT_EQUAL(sal_Int32(20210126), infos[0].SignatureDate); + // was: 0 + CPPUNIT_ASSERT_EQUAL(sal_Int32(18183742), infos[0].SignatureTime); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testODFX509CertificateChain) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "signed_with_x509certificate_chain.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + CPPUNIT_ASSERT_MESSAGE( + (OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), + (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(false)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + // check that the signing certificate was picked, not one of the 2 CA ones + CPPUNIT_ASSERT_EQUAL(security::CertificateValidity::VALID, infos[0].CertificateStatus); + CPPUNIT_ASSERT(infos[0].Signer.is()); + CPPUNIT_ASSERT_EQUAL( + OUString("CN=Xmlsecurity RSA Test example Alice,O=Xmlsecurity RSA Test,ST=England,C=UK"), + // CryptoAPI puts a space after comma, NSS does not... + infos[0].Signer->getSubjectName().replaceAll(", ", ",")); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testODFDoubleX509Data) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "02_doc_signed_by_attacker_manipulated.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + CPPUNIT_ASSERT_MESSAGE( + (OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), + (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(false)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + CPPUNIT_ASSERT_EQUAL(security::CertificateValidity::INVALID, infos[0].CertificateStatus); + CPPUNIT_ASSERT(!infos[0].Signer.is()); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testODFTripleX509Data) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "02_doc_signed_by_attacker_manipulated_triple.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + // here, libxmlsec will pick the 1st X509Data but signing key is the 2nd + CPPUNIT_ASSERT_EQUAL_MESSAGE((OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), + SignatureState::BROKEN, nActual); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(false)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + CPPUNIT_ASSERT_EQUAL(security::CertificateValidity::INVALID, infos[0].CertificateStatus); + CPPUNIT_ASSERT(!infos[0].Signer.is()); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testODFMacroDoubleX509Data) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "02_doc_macros_signed_by_attacker_manipulated.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetScriptingSignatureState(); + CPPUNIT_ASSERT_MESSAGE( + (OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), + (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(true)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + CPPUNIT_ASSERT_EQUAL(security::CertificateValidity::INVALID, infos[0].CertificateStatus); + CPPUNIT_ASSERT(!infos[0].Signer.is()); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testODFDoubleX509Certificate) +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "02_doc_signed_by_attacker_manipulated2.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + bool const nTemp((nActual == SignatureState::NOTVALIDATED + || nActual == SignatureState::OK +#if defined(_WIN32) + // oddly BCryptVerifySignature returns STATUS_INVALID_SIGNATURE + // while the same succeeds with NSS _SGN_VerifyPKCS1DigestInfo + || nActual == SignatureState::BROKEN +#endif + )); + CPPUNIT_ASSERT_MESSAGE((OString::number(/*o3tl::underlyingEnumValue(*/(int)nActual/*)*/).getStr()), nTemp); + uno::Sequence<security::DocumentSignatureInformation> const infos( + pObjectShell->GetDocumentSignatureInformation(false)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), infos.getLength()); + CPPUNIT_ASSERT_EQUAL(security::CertificateValidity::INVALID, infos[0].CertificateStatus); + CPPUNIT_ASSERT(!infos[0].Signer.is()); +} + +CPPUNIT_TEST_FIXTURE(SigningTest, testDNCompatibility) +{ + OUString const msDN("CN=\"\"\"ABC\"\".\", O=\"Enterprise \"\"ABC\"\"\""); + OUString const nssDN("CN=\\\"ABC\\\".,O=Enterprise \\\"ABC\\\""); + // this is just the status quo, possibly either NSS or CryptoAPI might change + CPPUNIT_ASSERT(!xmlsecurity::EqualDistinguishedNames(msDN, nssDN, xmlsecurity::NOCOMPAT)); + CPPUNIT_ASSERT(!xmlsecurity::EqualDistinguishedNames(nssDN, msDN, xmlsecurity::NOCOMPAT)); + // with compat flag it should work, with the string one 2nd and the native one 1st +#ifdef _WIN32 + CPPUNIT_ASSERT(xmlsecurity::EqualDistinguishedNames(msDN, nssDN, xmlsecurity::COMPAT_2ND)); +#else + CPPUNIT_ASSERT(xmlsecurity::EqualDistinguishedNames(nssDN, msDN, xmlsecurity::COMPAT_2ND)); +#endif +} + +/// Test a typical OOXML where a number of (but not all) streams are signed. void SigningTest::testOOXMLPartial() { createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "partial.docx"); diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index fd8648d26c8a..385f5121d14c 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -647,8 +647,17 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted( for ( ; pAuthors != pAuthorsEnd; ++pAuthors ) { SvtSecurityOptions::Certificate aAuthor = *pAuthors; - if (xmlsecurity::EqualDistinguishedNames(aAuthor[0], xAuthor->getIssuerName()) - && (aAuthor[1] == sSerialNum)) + if (!xmlsecurity::EqualDistinguishedNames(aAuthor[0], xAuthor->getIssuerName(), xmlsecurity::NOCOMPAT)) + continue; + if (aAuthor[1] != sSerialNum) + continue; + + DocumentSignatureManager aSignatureManager(mxCtx, {}); + if (!aSignatureManager.init()) + return false; + uno::Reference<css::security::XCertificate> xCert = + aSignatureManager.getSecurityEnvironment()->createCertificateFromAscii(aAuthor[2]); + if (xCert->getSHA1Thumbprint() == xAuthor->getSHA1Thumbprint()) { bFound = true; break; diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx index a2447cab5b80..5ac4a9e3a81d 100644 --- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx +++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx @@ -139,7 +139,12 @@ void OOXMLSecExporter::Impl::writeCanonicalizationTransform() void OOXMLSecExporter::Impl::writeSignatureMethod() { rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList()); - pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256); + + if (m_rInformation.eAlgorithmID == svl::crypto::SignatureMethodAlgorithm::ECDSA) + pAttributeList->AddAttribute("Algorithm", ALGO_ECDSASHA256); + else + pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256); + m_xDocumentHandler->startElement( "SignatureMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get())); m_xDocumentHandler->endElement("SignatureMethod"); diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 9f35130df47c..ad3b12ca3a32 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -44,6 +44,7 @@ #include <comphelper/ofopxmlhelper.hxx> #include <comphelper/sequence.hxx> #include <tools/diagnose_ex.h> +#include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <boost/optional.hpp> @@ -408,6 +409,7 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorageStream(const css::uno::Ref catch(const uno::Exception&) { DBG_UNHANDLED_EXCEPTION("xmlsecurity.helper"); + mbError = true; } mpXSecController->releaseSignatureReader(); @@ -609,7 +611,7 @@ static auto CheckX509Data( start = i; // issuer isn't in the list break; } - if (xmlsecurity::EqualDistinguishedNames(certs[i]->getIssuerName(), certs[j]->getSubjectName())) + if (xmlsecurity::EqualDistinguishedNames(certs[i]->getIssuerName(), certs[j]->getSubjectName(), xmlsecurity::NOCOMPAT)) { if (i == j) // self signed { @@ -642,7 +644,7 @@ static auto CheckX509Data( if (chain[i] != j) { if (xmlsecurity::EqualDistinguishedNames( - certs[chain[i]]->getSubjectName(), certs[j]->getIssuerName())) + certs[chain[i]]->getSubjectName(), certs[j]->getIssuerName(), xmlsecurity::NOCOMPAT)) { if (chain.size() != i + 1) // already found issuee? { diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx index edb12d641cb9..c5c253b86f66 100644 --- a/xmlsecurity/source/helper/xsecverify.cxx +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -272,7 +272,7 @@ void XSecController::setX509Data( auto iter = rX509IssuerSerials.begin(); while (iter != rX509IssuerSerials.end()) { - if (xmlsecurity::EqualDistinguishedNames(issuerName, iter->first) + if (xmlsecurity::EqualDistinguishedNames(issuerName, iter->first, xmlsecurity::COMPAT_2ND) && serialNumber == iter->second) { data.back().X509IssuerName = iter->first; @@ -420,7 +420,7 @@ void XSecController::setX509CertDigest( { for (auto & it : rData) { - if (xmlsecurity::EqualDistinguishedNames(it.X509IssuerName, rX509IssuerName) + if (xmlsecurity::EqualDistinguishedNames(it.X509IssuerName, rX509IssuerName, xmlsecurity::COMPAT_BOTH) && it.X509SerialNumber == rX509SerialNumber) { it.CertDigest = rCertDigest; @@ -443,7 +443,7 @@ void XSecController::setX509CertDigest( { SAL_INFO("xmlsecurity.helper", "cannot parse X509Certificate"); } - else if (xmlsecurity::EqualDistinguishedNames(xCert->getIssuerName(),rX509IssuerName) + else if (xmlsecurity::EqualDistinguishedNames(xCert->getIssuerName(), rX509IssuerName, xmlsecurity::COMPAT_2ND) && xmlsecurity::bigIntegerToNumericString(xCert->getSerialNumber()) == rX509SerialNumber) { it.CertDigest = rCertDigest; diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index f339c1be480d..09ac700105b5 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -774,6 +774,61 @@ static HCERTSTORE getCertStoreForIntermediatCerts( return store; } +static bool CheckUnitTestStore(PCCERT_CHAIN_CONTEXT const pChainContext, DWORD ignoreFlags) +{ + bool ret = false; + OUString const v("LIBO_TEST_CRYPTOAPI_PKCS7"); + OUString var; + if (osl_Process_E_None != osl_getEnvironment(v.pData, &var.pData)) + { + return ret; + } + if (pChainContext->cChain == 0) + { + return ret; + } + PCERT_SIMPLE_CHAIN pSimpleChain = pChainContext->rgpChain[0]; + // check if untrusted root is the only problem + if (pSimpleChain->TrustStatus.dwErrorStatus & ~(CERT_TRUST_IS_UNTRUSTED_ROOT | ignoreFlags)) + { + return ret; + } + + // leak this store, re-opening is a waste of time in tests + static HCERTSTORE const hExtra = CertOpenStore( + CERT_STORE_PROV_FILENAME, + PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, + NULL, + CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, + OUString(var + "/test.p7b").getStr()); + assert(hExtra != NULL); + if (pSimpleChain->cElement < 1) + { + SAL_WARN("xmlsecurity.xmlsec", "unexpected empty chain"); + return ret; + } + PCCERT_CONTEXT const pRoot(pSimpleChain->rgpElement[pSimpleChain->cElement-1]->pCertContext); + PCCERT_CONTEXT const pIssuerCert = CertFindCertificateInStore( + hExtra, + PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_NAME, + &pRoot->pCertInfo->Subject, + NULL); + if (pIssuerCert) + { + // check that it signed itself + DWORD flags = CERT_STORE_SIGNATURE_FLAG; + BOOL result = CertVerifySubjectCertificateContext(pRoot, pIssuerCert, &flags); + if (result == TRUE && flags == 0) + { + ret = true; + } + } + CertFreeCertificateContext(pIssuerCert); + return ret; +} + //We return only valid or invalid, as long as the API documentation expresses //explicitly that all validation steps are carried out even if one or several //errors occur. See also @@ -877,7 +932,8 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( DWORD revocationFlags = CERT_TRUST_REVOCATION_STATUS_UNKNOWN | CERT_TRUST_IS_OFFLINE_REVOCATION; DWORD otherErrorsMask = ~revocationFlags; - if( !(pSimpleChain->TrustStatus.dwErrorStatus & otherErrorsMask)) + if (!(pSimpleChain->TrustStatus.dwErrorStatus & otherErrorsMask) + || CheckUnitTestStore(pChainContext, revocationFlags)) { //No errors except maybe those caused by missing revocation information @@ -906,6 +962,11 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( SAL_INFO("xmlsecurity.xmlsec", "Certificate is valid."); validity = css::security::CertificateValidity::VALID; } + else if (CheckUnitTestStore(pChainContext, 0)) + { + SAL_INFO("xmlsecurity.xmlsec", "root certificate found in extra test store"); + validity = css::security::CertificateValidity::VALID; + } else { SAL_INFO("xmlsecurity.xmlsec", "Certificate is invalid."); diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index b5f779db3029..d3e2c5008258 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -32,6 +32,7 @@ #include "oid.hxx" #include <rtl/locale.h> +#include <rtl/ustrbuf.hxx> #include <osl/nlsupport.h> #include <osl/process.h> #include <o3tl/char16_t2wchar_t.hxx> @@ -677,6 +678,67 @@ Sequence<OUString> SAL_CALL X509Certificate_MSCryptImpl::getSupportedServiceName namespace xmlsecurity { +// based on some guesswork and: +// https://datatracker.ietf.org/doc/html/rfc1485 +// https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certnametostra#CERT_X500_NAME_STR +// the main problem appears to be that in values NSS uses \ escapes but CryptoAPI requires " quotes around value +static OUString CompatDNNSS(OUString const& rDN) +{ + OUStringBuffer buf(rDN.getLength()); + enum { DEFAULT, INVALUE, INQUOTE } state(DEFAULT); + for (sal_Int32 i = 0; i < rDN.getLength(); ++i) + { + if (state == DEFAULT) + { + buf.append(rDN[i]); + if (rDN[i] == '=') + { + if (rDN.getLength() == i+1) + { + break; // invalid? + } + else + { + buf.append('"'); + state = INVALUE; + } + } + } + else if (state == INVALUE) + { + if (rDN[i] == '+' || rDN[i] == ',' || rDN[i] == ';') + { + buf.append('"'); + buf.append(rDN[i]); + state = DEFAULT; + } + else if (rDN[i] == '\\') + { + if (rDN.getLength() == i+1) + { + break; // invalid? + } + if (rDN[i+1] == '"') + { + buf.append('"'); + } + buf.append(rDN[i+1]); + ++i; + } + else + { + buf.append(rDN[i]); + } + if (i+1 == rDN.getLength()) + { + buf.append('"'); + state = DEFAULT; + } + } + } + return buf.makeStringAndClear(); +} + static bool EncodeDistinguishedName(OUString const& rName, CERT_NAME_BLOB & rBlob) { LPCWSTR pszError; @@ -699,22 +761,38 @@ static bool EncodeDistinguishedName(OUString const& rName, CERT_NAME_BLOB & rBlo } bool EqualDistinguishedNames( - OUString const& rName1, OUString const& rName2) + OUString const& rName1, OUString const& rName2, + EqualMode const eMode) { + if (eMode == COMPAT_BOTH && !rName1.isEmpty() && rName1 == rName2) + { // handle case where both need to be converted + return true; + } CERT_NAME_BLOB blob1; if (!EncodeDistinguishedName(rName1, blob1)) { return false; } CERT_NAME_BLOB blob2; - if (!EncodeDistinguishedName(rName2, blob2)) + bool ret(false); + if (!!EncodeDistinguishedName(rName2, blob2)) { - delete[] blob1.pbData; - return false; + ret = CertCompareCertificateName(X509_ASN_ENCODING, + &blob1, &blob2) == TRUE; + delete[] blob2.pbData; + } + if (!ret && eMode == COMPAT_2ND) + { + CERT_NAME_BLOB blob2compat; + if (!EncodeDistinguishedName(CompatDNNSS(rName2), blob2compat)) + { + delete[] blob1.pbData; + return false; + } + ret = CertCompareCertificateName(X509_ASN_ENCODING, + &blob1, &blob2compat) == TRUE; + delete[] blob2compat.pbData; } - bool const ret(CertCompareCertificateName(X509_ASN_ENCODING, - &blob1, &blob2) == TRUE); - delete[] blob2.pbData; delete[] blob1.pbData; return ret; } diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx index 6b16efd46752..a3a04b5c1241 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx @@ -229,6 +229,10 @@ SAL_CALL XMLSignature_MSCryptImpl::validate( // We do certificate verification ourselves. pDsigCtx->keyInfoReadCtx.flags |= XMLSEC_KEYINFO_FLAGS_X509DATA_DONT_VERIFY_CERTS; + // limit possible key data to valid X509 certificates only, no KeyValues + if (xmlSecPtrListAdd(&(pDsigCtx->keyInfoReadCtx.enabledKeyData), BAD_CAST xmlSecMSCngKeyDataX509GetKlass()) < 0) + throw RuntimeException("failed to limit allowed key data"); + //Verify signature //The documentation says that the signature is only valid if the return value is 0 (that is, not < 0) //AND pDsigCtx->status == xmlSecDSigStatusSucceeded. That is, we must not make any assumptions, if diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx index db9ac25b2cbc..50caf51081f2 100644 --- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx @@ -29,6 +29,8 @@ #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <rtl/ref.hxx> +#include <rtl/ustrbuf.hxx> +#include <sal/log.hxx> #include "x509certificate_nssimpl.hxx" #include <biginteger.hxx> @@ -549,22 +551,103 @@ Sequence<OUString> SAL_CALL X509Certificate_NssImpl::getSupportedServiceNames() namespace xmlsecurity { +// based on some guesswork and: +// https://datatracker.ietf.org/doc/html/rfc1485 +// https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certnametostra#CERT_X500_NAME_STR +// the main problem appears to be that in values " is escaped as "" vs. \" +static OUString CompatDNCryptoAPI(OUString const& rDN) +{ + OUStringBuffer buf(rDN.getLength()); + enum { DEFAULT, INVALUE, INQUOTE } state(DEFAULT); + for (sal_Int32 i = 0; i < rDN.getLength(); ++i) + { + if (state == DEFAULT) + { + buf.append(rDN[i]); + if (rDN[i] == '=') + { + if (rDN.getLength() == i+1) + { + break; // invalid? + } + else if (rDN[i+1] == '"') + { + buf.append(rDN[i+1]); + ++i; + state = INQUOTE; + } + else + { + state = INVALUE; + } + } + } + else if (state == INVALUE) + { + if (rDN[i] == '+' || rDN[i] == ',' || rDN[i] == ';') + { + state = DEFAULT; + } + buf.append(rDN[i]); + } + else + { + assert(state == INQUOTE); + if (rDN[i] == '"') + { + if (rDN.getLength() != i+1 && rDN[i+1] == '"') + { + buf.append('\\'); + buf.append(rDN[i+1]); + ++i; + } + else + { + buf.append(rDN[i]); + state = DEFAULT; + } + } + else + { + buf.append(rDN[i]); + } + } + } + return buf.makeStringAndClear(); +} + bool EqualDistinguishedNames( - OUString const& rName1, OUString const& rName2) + OUString const& rName1, OUString const& rName2, + EqualMode const eMode) { + if (eMode == COMPAT_BOTH && !rName1.isEmpty() && rName1 == rName2) + { // handle case where both need to be converted + return true; + } CERTName *const pName1(CERT_AsciiToName(OUStringToOString(rName1, RTL_TEXTENCODING_UTF8).getStr())); if (pName1 == nullptr) { return false; } CERTName *const pName2(CERT_AsciiToName(OUStringToOString(rName2, RTL_TEXTENCODING_UTF8).getStr())); - if (pName2 == nullptr) + bool ret(false); + if (pName2) { - CERT_DestroyName(pName1); - return false; + ret = (CERT_CompareName(pName1, pName2) == SECEqual); + CERT_DestroyName(pName2); + } + if (!ret && eMode == COMPAT_2ND) + { + CERTName *const pName2Compat(CERT_AsciiToName(OUStringToOString( + CompatDNCryptoAPI(rName2), RTL_TEXTENCODING_UTF8).getStr())); + if (pName2Compat == nullptr) + { + CERT_DestroyName(pName1); + return false; + } + ret = CERT_CompareName(pName1, pName2Compat) == SECEqual; + CERT_DestroyName(pName2Compat); } - bool const ret(CERT_CompareName(pName1, pName2) == SECEqual); - CERT_DestroyName(pName2); CERT_DestroyName(pName1); return ret; } diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx index e50daa47e868..c4e21d791c2d 100644 --- a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx @@ -244,6 +244,10 @@ SAL_CALL XMLSignature_NssImpl::validate( // We do certificate verification ourselves. pDsigCtx->keyInfoReadCtx.flags |= XMLSEC_KEYINFO_FLAGS_X509DATA_DONT_VERIFY_CERTS; + // limit possible key data to valid X509 certificates only, no KeyValues + if (xmlSecPtrListAdd(&(pDsigCtx->keyInfoReadCtx.enabledKeyData), BAD_CAST xmlSecNssKeyDataX509GetKlass()) < 0) + throw RuntimeException("failed to limit allowed key data"); + //Verify signature int rs = xmlSecDSigCtxVerify( pDsigCtx.get() , pNode ); |