[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - 8 commits - binaryurp/source bridges/source configure.ac desktop/source external/jpeg-turbo external/openssl helpcompiler/source include/o3tl shell/source ucb/source

Andras Timar (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 10 18:56:02 UTC 2019


 binaryurp/source/incomingrequest.cxx                  |    7 
 binaryurp/source/proxy.cxx                            |    6 
 bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx  |   19 --
 bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx |   18 -
 configure.ac                                          |    2 
 desktop/source/app/app.cxx                            |    3 
 external/jpeg-turbo/jpeg-turbo.build.patch.1          |    8 
 external/jpeg-turbo/jpeg-turbo.win_build.patch.1      |    4 
 external/jpeg-turbo/ubsan.patch                       |   20 ++
 external/openssl/ExternalProject_openssl.mk           |    2 
 external/openssl/UnpackedTarball_openssl.mk           |    1 
 external/openssl/openssl-vs120-fixbuild.patch         |   11 +
 external/openssl/openssllnx.patch                     |    2 
 helpcompiler/source/HelpIndexer.cxx                   |    3 
 include/o3tl/runtimetooustring.hxx                    |   48 +++++
 shell/source/unix/exec/shellexec.cxx                  |   37 ++++
 shell/source/win32/SysShExec.cxx                      |  163 ++++++++++++++++--
 ucb/source/ucp/cmis/cmis_content.cxx                  |   15 -
 18 files changed, 299 insertions(+), 70 deletions(-)

New commits:
commit 2a559976dd5c77cab8a6464db07b6bd481f8d420
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Wed Apr 10 07:27:50 2019 -0700
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 07:27:50 2019 -0700

    Bump version to 5.3-64
    
    Change-Id: I9c7b8ca6cd3e846657c0820337bae4d76822229d

diff --git a/configure.ac b/configure.ac
index 12f76b089db1..d51bd382c7cd 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([Collabora Office],[5.3.10.63],[],[],[https://collaboraoffice.com/])
+AC_INIT([Collabora Office],[5.3.10.64],[],[],[https://collaboraoffice.com/])
 
 AC_PREREQ([2.59])
 
commit f9f1c8c3ac8d300d9f28accd4880e8ca08341838
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Mar 29 14:01:19 2019 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 07:25:57 2019 -0700

    Filter out problematic file URLs
    
    Change-Id: I87fd37e56326bef4888354b923407530c6f70760
    Reviewed-on: https://gerrit.libreoffice.org/70177
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
index 71f01e764a56..f94c2ef6eff0 100644
--- a/shell/source/unix/exec/shellexec.cxx
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -42,6 +42,10 @@
 #include <errno.h>
 #include <unistd.h>
 
+#if defined MACOSX
+#include <sys/stat.h>
+#endif
+
 using com::sun::star::system::XSystemShellExecute;
 using com::sun::star::system::SystemShellExecuteException;
 
@@ -122,6 +126,39 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
         }
 
 #ifdef MACOSX
+        if (uri->getScheme().equalsIgnoreAsciiCase("file")) {
+            OUString pathname;
+            auto const e1 = osl::FileBase::getSystemPathFromFileURL(aCommand, pathname);
+            if (e1 != osl::FileBase::E_None) {
+                throw css::lang::IllegalArgumentException(
+                    ("XSystemShellExecute.execute, getSystemPathFromFileURL <" + aCommand
+                     + "> failed with " + OUString::number(e1)),
+                    {}, 0);
+            }
+            OString pathname8;
+            if (!pathname.convertToString(
+                    &pathname8, RTL_TEXTENCODING_UTF8,
+                    (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+                     | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
+            {
+                throw css::lang::IllegalArgumentException(
+                    "XSystemShellExecute.execute, cannot convert \"" + pathname + "\" to UTF-8", {},
+                    0);
+            }
+            struct stat st;
+            auto const e2 = stat(pathname8.getStr(), &st);
+            if (e2 != 0) {
+                auto const e3 = errno;
+                SAL_INFO("shell", "stat(" << pathname8 << ") failed with errno " << e3);
+            }
+            if (e2 != 0 || !S_ISREG(st.st_mode)
+                || (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)
+            {
+                throw css::lang::IllegalArgumentException(
+                    "XSystemShellExecute.execute, cannot process <" + aCommand + ">", {}, 0);
+            }
+        }
+
         //TODO: Using open(1) with an argument that syntactically is an absolute
         // URI reference does not necessarily give expected results:
         // 1  If the given URI reference matches a supported scheme (e.g.,
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
index 5edb22a1a821..3197ba42db5e 100644
--- a/shell/source/win32/SysShExec.cxx
+++ b/shell/source/win32/SysShExec.cxx
@@ -18,8 +18,11 @@
  */
 
 #include <algorithm>
+#include <cassert>
 
 #include <osl/diagnose.h>
+#include <osl/process.h>
+#include <sal/log.hxx>
 #include "SysShExec.hxx"
 #include <osl/file.hxx>
 #include <sal/macros.h>
@@ -27,6 +30,7 @@
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 #include <com/sun/star/uri/UriReferenceFactory.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <o3tl/runtimetooustring.hxx>
 
 #define WIN32_LEAN_AND_MEAN
 #if defined _MSC_VER
@@ -34,7 +38,9 @@
 #endif
 #include <windows.h>
 #include <shellapi.h>
+#include <Shobjidl.h>
 #include <objbase.h>
+#include <systools/win32/comtools.hxx>
 #if defined _MSC_VER
 #pragma warning(pop)
 #endif
@@ -245,6 +251,18 @@ CSysShExec::CSysShExec( const Reference< css::uno::XComponentContext >& xContext
 
 namespace
 {
+bool checkExtension(OUString const & extension, OUString const & blacklist) {
+    assert(!extension.isEmpty());
+    for (sal_Int32 i = 0; i != -1;) {
+        OUString tok = blacklist.getToken(0, ';', i);
+        tok.startsWith(".", &tok);
+        if (extension.equalsIgnoreAsciiCase(tok)) {
+            return false;
+        }
+    }
+    return true;
+}
+
 // This callback checks if the found window is the specified process's top-level window,
 // and activates the first found such window.
 BOOL CALLBACK FindAndActivateProcWnd(HWND hwnd, LPARAM lParam)
@@ -299,6 +317,102 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa
                  + aCommand,
                 static_cast< cppu::OWeakObject * >(this), 0);
         }
+        if (uri->getScheme().equalsIgnoreAsciiCase("file")) {
+            OUString pathname;
+            auto const e1 = osl::FileBase::getSystemPathFromFileURL(aCommand, pathname);
+            if (e1 != osl::FileBase::E_None) {
+                throw css::lang::IllegalArgumentException(
+                    ("XSystemShellExecute.execute, getSystemPathFromFileURL <" + aCommand
+                     + "> failed with " + OUString::number(e1)),
+                    {}, 0);
+            }
+            for (int i = 0;; ++i) {
+                SHFILEINFOW info;
+                if (SHGetFileInfoW(
+                        reinterpret_cast<LPCWSTR>(pathname.getStr()), 0, &info, sizeof info, SHGFI_EXETYPE)
+                    != 0)
+                {
+                    throw css::lang::IllegalArgumentException(
+                        "XSystemShellExecute.execute, cannot process <" + aCommand + ">", {}, 0);
+                }
+                if (SHGetFileInfoW(
+                        reinterpret_cast<LPCWSTR>(pathname.getStr()), 0, &info, sizeof info, SHGFI_ATTRIBUTES)
+                    == 0)
+                {
+                    throw css::lang::IllegalArgumentException(
+                        "XSystemShellExecute.execute, SHGetFileInfoW(" + pathname + ") failed", {},
+                        0);
+                }
+                if ((info.dwAttributes & SFGAO_LINK) == 0) {
+                    break;
+                }
+                sal::systools::COMReference<IShellLinkW> link;
+                auto e2 = CoCreateInstance(
+                    CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW,
+                    reinterpret_cast<LPVOID *>(&link));
+                if (FAILED(e2)) {
+                    throw css::lang::IllegalArgumentException(
+                        ("XSystemShellExecute.execute, CoCreateInstance failed with "
+                         + OUString::number(e2)),
+                        {}, 0);
+                }
+                sal::systools::COMReference<IPersistFile> file;
+                try {
+                    file = link.QueryInterface<IPersistFile>(IID_IPersistFile);
+                } catch(sal::systools::ComError & e3) {
+                    throw css::lang::IllegalArgumentException(
+                        ("XSystemShellExecute.execute, QueryInterface failed with: "
+                         + o3tl::runtimeToOUString(e3.what())),
+                        {}, 0);
+                }
+                e2 = file->Load(reinterpret_cast<LPCWSTR>(pathname.getStr()), STGM_READ);
+                if (FAILED(e2)) {
+                    throw css::lang::IllegalArgumentException(
+                        ("XSystemShellExecute.execute, IPersistFile.Load failed with "
+                         + OUString::number(e2)),
+                        {}, 0);
+                }
+                e2 = link->Resolve(nullptr, SLR_UPDATE | SLR_NO_UI);
+                if (FAILED(e2)) {
+                    throw css::lang::IllegalArgumentException(
+                        ("XSystemShellExecute.execute, IShellLink.Resolve failed with "
+                         + OUString::number(e2)),
+                        {}, 0);
+                }
+                wchar_t path[MAX_PATH];
+                WIN32_FIND_DATAW wfd;
+                e2 = link->GetPath(path, MAX_PATH, &wfd, SLGP_RAWPATH);
+                if (FAILED(e2)) {
+                    throw css::lang::IllegalArgumentException(
+                        ("XSystemShellExecute.execute, IShellLink.GetPath failed with "
+                         + OUString::number(e2)),
+                        {}, 0);
+                }
+                pathname = OUString( reinterpret_cast<const sal_Unicode*>(path) );
+                // Fail at some arbitrary nesting depth, to avoid an infinite loop:
+                if (i == 30) {
+                    throw css::lang::IllegalArgumentException(
+                        "XSystemShellExecute.execute, link depth exceeded for <" + aCommand + ">",
+                        {}, 0);
+                }
+            }
+            auto const n = pathname.lastIndexOf('.');
+            if (n > pathname.lastIndexOf('\\')) {
+                auto const ext = pathname.copy(n + 1);
+                OUString env;
+                if (osl_getEnvironment(OUString("PATHEXT").pData, &env.pData) != osl_Process_E_None)
+                {
+                    SAL_INFO("shell", "osl_getEnvironment(PATHEXT) failed");
+                }
+                if (!(checkExtension(ext, env)
+                      && checkExtension(
+                          ext, ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY")))
+                {
+                    throw css::lang::IllegalArgumentException(
+                        "XSystemShellExecute.execute, cannot process <" + aCommand + ">", {}, 0);
+                }
+            }
+        }
     }
 
     /*  #i4789#; jump mark detection on system paths
commit e601e7bcadeb0fa1877a54d86f3d8c384574ab72
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Nov 23 23:10:29 2016 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    New o3tl::runtimeToOUString to convert from C++ runtime NTBS to OUString
    
    Change-Id: I613bb70b6828f615fd45af38b2d873ece55ace60

diff --git a/binaryurp/source/incomingrequest.cxx b/binaryurp/source/incomingrequest.cxx
index cf66f9c7286d..a1c4ef39090f 100644
--- a/binaryurp/source/incomingrequest.cxx
+++ b/binaryurp/source/incomingrequest.cxx
@@ -25,6 +25,7 @@
 
 #include "com/sun/star/bridge/XInstanceProvider.hpp"
 #include "cppuhelper/exc_hlp.hxx"
+#include "o3tl/runtimetooustring.hxx"
 #include "rtl/byteseq.hxx"
 #include "rtl/ref.hxx"
 #include "rtl/ustring.hxx"
@@ -77,10 +78,8 @@ void IncomingRequest::execute() const {
                 isExc = !execute_throw(&ret, &outArgs);
             } catch (const std::exception & e) {
                 throw css::uno::RuntimeException(
-                    "caught C++ exception: " +
-                    OStringToOUString(
-                         OString(e.what()), RTL_TEXTENCODING_ASCII_US));
-                    // best-effort string conversion
+                    "caught C++ exception: "
+                    + o3tl::runtimeToOUString(e.what()));
             }
         } catch (const css::uno::RuntimeException &) {
             css::uno::Any exc(cppu::getCaughtException());
diff --git a/binaryurp/source/proxy.cxx b/binaryurp/source/proxy.cxx
index 5f23b4647208..1834968fa50b 100644
--- a/binaryurp/source/proxy.cxx
+++ b/binaryurp/source/proxy.cxx
@@ -24,6 +24,7 @@
 #include <vector>
 
 #include "cppuhelper/exc_hlp.hxx"
+#include "o3tl/runtimetooustring.hxx"
 #include "rtl/ref.hxx"
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
@@ -100,10 +101,7 @@ void Proxy::do_dispatch(
             do_dispatch_throw(member, returnValue, arguments, exception);
         } catch (const std::exception & e) {
             throw css::uno::RuntimeException(
-                "caught C++ exception: " +
-                OStringToOUString(
-                    OString(e.what()), RTL_TEXTENCODING_ASCII_US));
-                // best-effort string conversion
+                "caught C++ exception: " + o3tl::runtimeToOUString(e.what()));
         }
     } catch (const css::uno::RuntimeException &) {
         css::uno::Any exc(cppu::getCaughtException());
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
index 71e76a9f3b09..fb7bf08a81b3 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
@@ -23,10 +23,10 @@
 #include <typeinfo>
 
 #include "rtl/alloc.h"
-#include "rtl/ustrbuf.hxx"
 
 #include <com/sun/star/uno/genfunc.hxx>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -95,14 +95,6 @@ void INSERT_INT8(
         *pDS++ = *static_cast<sal_uInt8 const *>( pSV );
 }
 
-void appendCString(OUStringBuffer & buffer, char const * text) {
-    if (text != nullptr) {
-        buffer.append(
-            OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1));
-            // use 8859-1 to avoid conversion failure
-    }
-}
-
 }
 
 static void cpp_call(
@@ -246,12 +238,9 @@ static void cpp_call(
         } catch (const Exception &) {
             throw;
         } catch (const std::exception & e) {
-            OUStringBuffer buf;
-            buf.append("C++ code threw ");
-            appendCString(buf, typeid(e).name());
-            buf.append(": ");
-            appendCString(buf, e.what());
-            throw RuntimeException(buf.makeStringAndClear());
+            throw RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name())
+                + ": " + o3tl::runtimeToOUString(e.what()));
         } catch (...) {
             throw RuntimeException("C++ code threw unknown exception");
         }
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
index f606f7275990..9770dba7d4ba 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
@@ -23,10 +23,10 @@
 #include <typeinfo>
 
 #include "rtl/alloc.h"
-#include "rtl/ustrbuf.hxx"
 
 #include <com/sun/star/uno/genfunc.hxx>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -95,14 +95,6 @@ void INSERT_INT8(
         *pDS++ = *static_cast<sal_uInt8 const *>( pSV );
 }
 
-void appendCString(OUStringBuffer & buffer, char const * text) {
-    if (text != nullptr) {
-        buffer.append(
-            OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1));
-            // use 8859-1 to avoid conversion failure
-    }
-}
-
 }
 
 static void cpp_call(
@@ -246,13 +238,9 @@ static void cpp_call(
         } catch (const Exception &) {
             throw;
         } catch (const std::exception & e) {
-            OUStringBuffer buf;
-            buf.append("C++ code threw ");
-            appendCString(buf, typeid(e).name());
-            buf.append(": ");
-            appendCString(buf, e.what());
             throw RuntimeException(
-                buf.makeStringAndClear());
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name())
+                + ": " + o3tl::runtimeToOUString(e.what()));
         } catch (...) {
             throw RuntimeException("C++ code threw unknown exception");
         }
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 10fadb86626b..8fc694e2d59d 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -38,6 +38,7 @@
 #include "desktopcontext.hxx"
 #include "migration.hxx"
 
+#include <o3tl/runtimetooustring.hxx>
 #include <svl/languageoptions.hxx>
 #include <svtools/javacontext.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -1738,7 +1739,7 @@ int Desktop::Main()
         catch( const std::exception& exSTD)
         {
             RequestHandler::SetDowning();
-            FatalError( OUString::createFromAscii( exSTD.what()));
+            FatalError(o3tl::runtimeToOUString(exSTD.what()));
         }
         catch( ...)
         {
diff --git a/helpcompiler/source/HelpIndexer.cxx b/helpcompiler/source/HelpIndexer.cxx
index e6a26fce3d28..0c10da99d0c5 100644
--- a/helpcompiler/source/HelpIndexer.cxx
+++ b/helpcompiler/source/HelpIndexer.cxx
@@ -12,6 +12,7 @@
 #include <rtl/string.hxx>
 #include <rtl/uri.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <osl/file.hxx>
 #include <osl/thread.h>
 #include <algorithm>
@@ -72,7 +73,7 @@ bool HelpIndexer::indexDocuments()
     }
     catch (CLuceneError &e)
     {
-        d_error = OUString::createFromAscii(e.what());
+        d_error = o3tl::runtimeToOUString(e.what());
         return false;
     }
 
diff --git a/include/o3tl/runtimetooustring.hxx b/include/o3tl/runtimetooustring.hxx
new file mode 100644
index 000000000000..7f2015805722
--- /dev/null
+++ b/include/o3tl/runtimetooustring.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
+#define INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
+
+#include <sal/config.h>
+
+#include <cassert>
+#include <cstring>
+
+#include <rtl/textcvt.h>
+#include <rtl/textenc.h>
+#include <rtl/ustring.h>
+#include <rtl/ustring.hxx>
+
+namespace o3tl {
+
+/** Convert an NTBS from the C++ runtime to an OUString.
+
+    This is used to convert an NTBS as provided by std::exception::what or
+    std::type_info::name into an OUString in a "lossless" way.  The conversion
+    is done using RTL_TEXTENCODING_ISO_8859_1, so each char in the input maps
+    to one Unicode character in the output.
+*/
+inline OUString runtimeToOUString(char const * runtimeString) {
+    OUString s;
+    bool ok = rtl_convertStringToUString(
+        &s.pData, runtimeString, std::strlen(runtimeString),
+        RTL_TEXTENCODING_ISO_8859_1,
+        (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
+         | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
+         | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR));
+    assert(ok); (void) ok;
+    return s;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index c3fca0792a7d..c5fa4a555c82 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -43,6 +43,7 @@
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <config_oauth2.h>
+#include <o3tl/runtimetooustring.hxx>
 #include <ucbhelper/cancelcommandexecution.hxx>
 #include <ucbhelper/content.hxx>
 #include <ucbhelper/contentidentifier.hxx>
@@ -1133,7 +1134,7 @@ namespace cmis
                                 ucb::IOErrorCode_GENERAL,
                                 uno::Sequence< uno::Any >( 0 ),
                                 xEnv,
-                                OUString::createFromAscii( e.what() ) );
+                                o3tl::runtimeToOUString(e.what()));
         }
         return aRet;
     }
@@ -1199,7 +1200,7 @@ namespace cmis
                                 ucb::IOErrorCode_GENERAL,
                                 uno::Sequence< uno::Any >( 0 ),
                                 xEnv,
-                                OUString::createFromAscii( e.what() ) );
+                                o3tl::runtimeToOUString(e.what()));
         }
         return aRet;
     }
@@ -1240,7 +1241,7 @@ namespace cmis
                     ucb::IOErrorCode_GENERAL,
                     uno::Sequence< uno::Any >( 0 ),
                     xEnv,
-                    OUString::createFromAscii( e.what() ) );
+                    o3tl::runtimeToOUString(e.what()));
         }
         return uno::Sequence< document::CmisVersion > ( );
     }
@@ -1449,7 +1450,7 @@ namespace cmis
                                 ucb::IOErrorCode_GENERAL,
                                 uno::Sequence< uno::Any >( 0 ),
                                 xEnv,
-                                OUString::createFromAscii( e.what() ) );
+                                o3tl::runtimeToOUString(e.what()));
         }
 
         sal_Int32 nCount = rValues.getLength();
@@ -1517,7 +1518,7 @@ namespace cmis
                                 ucb::IOErrorCode_GENERAL,
                                 uno::Sequence< uno::Any >( 0 ),
                                 xEnv,
-                                OUString::createFromAscii( e.what() ) );
+                                o3tl::runtimeToOUString(e.what()));
         }
 
         return aRet;
@@ -1564,7 +1565,7 @@ namespace cmis
                                 ucb::IOErrorCode_GENERAL,
                                 uno::Sequence< uno::Any >( 0 ),
                                 xEnv,
-                                OUString::createFromAscii( e.what() ) );
+                                o3tl::runtimeToOUString(e.what()));
         }
 
         return true;
@@ -1843,7 +1844,7 @@ namespace cmis
                                     ucb::IOErrorCode_GENERAL,
                                     uno::Sequence< uno::Any >( 0 ),
                                     xEnv,
-                                    OUString::createFromAscii( e.what() ) );
+                                    o3tl::runtimeToOUString(e.what()));
             }
         }
         else if ( aCommand.Name == "checkout" )
commit 2a7a01b02bdf0695da8c0d4c2250ad6289da9026
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Oct 28 19:14:28 2018 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    tdf#120703 PVS: V547 Fix activation of launched process' window
    
    V547 Expression 'procHandle != nullptr' is always false.
    
    The code was nonsensical overall. First, the launched process handle
    was never returned by ShellExecuteExW, because SEE_MASK_NOCLOSEPROCESS
    wasn't used, so GetProcessId couldn't succeed. Then, nullptr window
    handle was passed to GetWindowThreadProcessId, thus never returning a
    meaningful result.
    
    This reimplements this to find the launched process' main window by
    first waiting for process idle (up to 1-second delay is possible),
    then enumerating all the top-level windows and checking their process.
    
    Change-Id: I5fb4c04147b3f9414e27650a023f7844523c18bd
    Reviewed-on: https://gerrit.libreoffice.org/62478
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
index 6cb31942ba02..5edb22a1a821 100644
--- a/shell/source/win32/SysShExec.cxx
+++ b/shell/source/win32/SysShExec.cxx
@@ -243,6 +243,34 @@ CSysShExec::CSysShExec( const Reference< css::uno::XComponentContext >& xContext
     CoInitialize( nullptr );
 }
 
+namespace
+{
+// This callback checks if the found window is the specified process's top-level window,
+// and activates the first found such window.
+BOOL CALLBACK FindAndActivateProcWnd(HWND hwnd, LPARAM lParam)
+{
+    if (!IsWindowVisible(hwnd))
+        return TRUE; // continue enumeration
+    if (GetWindow(hwnd, GW_OWNER)) // not a top-level window
+        return TRUE; // continue enumeration
+    const DWORD nParamProcId = static_cast<DWORD>(lParam);
+    assert(nParamProcId != 0);
+    DWORD nWndProcId = 0;
+    (void)GetWindowThreadProcessId(hwnd, &nWndProcId);
+    if (nWndProcId != nParamProcId)
+        return TRUE; // continue enumeration
+
+    // Found it! Bring it to front
+    if (IsIconic(hwnd))
+    {
+        ShowWindow(hwnd, SW_RESTORE);
+    }
+    SetForegroundWindow(hwnd);
+    SetActiveWindow(hwnd);
+    return FALSE; // stop enumeration
+}
+}
+
 void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags )
         throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException)
 {
@@ -300,9 +328,10 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa
     sei.lpFile       = reinterpret_cast<LPCWSTR>(preprocessed_command.getStr());
     sei.lpParameters = reinterpret_cast<LPCWSTR>(aParameter.getStr());
     sei.nShow        = SW_SHOWNORMAL;
+    sei.fMask = SEE_MASK_NOCLOSEPROCESS; // we need sei.hProcess
 
     if (NO_SYSTEM_ERROR_MESSAGE & nFlags)
-        sei.fMask = SEE_MASK_FLAG_NO_UI;
+        sei.fMask |= SEE_MASK_FLAG_NO_UI;
 
     SetLastError( 0 );
 
@@ -326,20 +355,12 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa
     else
     {
         // Get Permission make changes to the Window of the created Process
-        HWND procHandle = 0;
-        DWORD procId = GetProcessId(sei.hProcess);
-        AllowSetForegroundWindow(procId);
-
-        // Get the handle of the created Window
-        DWORD check = 0;
-        GetWindowThreadProcessId(procHandle, &check);
-        SAL_WARN_IF(check != procId, "shell", "Could not get handle of process called by shell.");
-
-        // Move created Window into the foreground
-        if(procHandle != 0)
+        const DWORD procId = GetProcessId(sei.hProcess);
+        if (procId != 0)
         {
-            SetForegroundWindow(procHandle);
-            SetActiveWindow(procHandle);
+            AllowSetForegroundWindow(procId);
+            WaitForInputIdle(sei.hProcess, 1000); // so that main window is created; imperfect
+            EnumWindows(FindAndActivateProcWnd, static_cast<LPARAM>(procId));
         }
     }
 
commit 550337554de5577f8c71496d3163ae7603772738
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Wed Apr 10 04:37:24 2019 -0700
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    fix build of openssl with VS120
    
    In openssl-1.0.2o the -WX switch was introduced (treat warnings as errors).
    This caused a problem with Visual Studio 2013:
        ./crypto/des/set_key.c(70) : error C2220: warning treated as error - no 'object' file generated
        ./crypto/des/set_key.c(70) : warning C4172: returning address of local variable or temporary
    The code in question has been unchanged for long, so supressing this warning looked like a plausible
    solution.
    
    Change-Id: Ie771f0f1fea6d4a7edc2e2ecb3a6d8dcf4c30368

diff --git a/external/openssl/UnpackedTarball_openssl.mk b/external/openssl/UnpackedTarball_openssl.mk
index 9fc5f72656e3..dc125c218623 100644
--- a/external/openssl/UnpackedTarball_openssl.mk
+++ b/external/openssl/UnpackedTarball_openssl.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,openssl,\
 	external/openssl/opensslosxppc.patch \
 	external/openssl/openssl-3650-masm.patch.1 \
 	external/openssl/openssl-fixbuild.patch.1 \
+   	external/openssl/openssl-vs120-fixbuild.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/openssl/openssl-vs120-fixbuild.patch b/external/openssl/openssl-vs120-fixbuild.patch
new file mode 100644
index 000000000000..860bacc0a9db
--- /dev/null
+++ b/external/openssl/openssl-vs120-fixbuild.patch
@@ -0,0 +1,11 @@
+--- a/openssl/Configure	2019-04-10 04:08:39.363283300 -0700
++++ b/openssl/Configure	2019-04-10 04:12:57.481560200 -0700
+@@ -595,7 +595,7 @@
+ "debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
+ # x86 Win32 target defaults to ANSI API, if you want UNICODE, complement
+ # 'perl Configure VC-WIN32' with '-DUNICODE -D_UNICODE'
+-"VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
++"VC-WIN32","cl:-W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
+ # Unified CE target
+ "debug-VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
+ "VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32",
commit 271d9fe149c6fc8344eda7a1b926adc51a8f941d
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Apr 8 14:25:47 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    openssl: try to fix build with 7.1A SDK
    
    Change-Id: Ic4a9e53227e34fe41a69afd52a9e91ef9545f8f9

diff --git a/external/openssl/ExternalProject_openssl.mk b/external/openssl/ExternalProject_openssl.mk
index aa25c3a776de..9f89dd9c9116 100644
--- a/external/openssl/ExternalProject_openssl.mk
+++ b/external/openssl/ExternalProject_openssl.mk
@@ -61,7 +61,7 @@ OPENSSL_PLATFORM := \
 ifeq ($(COM),MSC)
 $(call gb_ExternalProject_get_state_target,openssl,build):
 	$(call gb_ExternalProject_run,build,\
-		export CC="$(shell cygpath -w $(filter-out -%,$(CC))) $(filter -%,$(CC))" \
+		export CC="$(shell cygpath -w $(filter-out -%,$(CC))) $(filter -%,$(CC)) $(if $(findstring 120_70,$(VCVER)_$(WINDOWS_SDK_VERSION)),-D_USING_V110_SDK71_)" \
 		&& export PERL="$(shell cygpath -w $(PERL))" \
 		&& export LIB="$(ILIB)" \
 		&& $(PERL) Configure $(OPENSSL_PLATFORM) no-idea \
commit 0502bf64c0116ae2682db39795597f35a2eee8c5
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Wed Apr 10 02:31:00 2019 -0700
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    fix patching of openssl
    
    Change-Id: I43c477e500dec6d98a8cb3814a0680e9db2da709

diff --git a/external/openssl/openssllnx.patch b/external/openssl/openssllnx.patch
index de19807b313e..224df8f87b2e 100644
--- a/external/openssl/openssllnx.patch
+++ b/external/openssl/openssllnx.patch
@@ -19,5 +19,5 @@
 -		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
 +		AS='$(CC)' ASFLAG='$(CFLAG) -c -Wa,--noexecstack'       \
  		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
+ 		RC='$(RC)'              			\
  		CROSS_COMPILE='$(CROSS_COMPILE)'	\
- 		PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'		\
commit 0c03f5523a14bb3dd06c3c1e4136ee71b7840e76
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Wed Apr 10 05:11:10 2019 -0700
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 10 06:42:58 2019 -0700

    fix build of libjpeg-turbo
    
    Change-Id: Ic976952a33a96f45c8b09e16509e2b42d4ad1fc0

diff --git a/external/jpeg-turbo/jpeg-turbo.build.patch.1 b/external/jpeg-turbo/jpeg-turbo.build.patch.1
index 85cd7f645173..4d01ad4b9aed 100644
--- a/external/jpeg-turbo/jpeg-turbo.build.patch.1
+++ b/external/jpeg-turbo/jpeg-turbo.build.patch.1
@@ -24,10 +24,10 @@ diff -ru jpeg-turbo.orig/Makefile.in jpeg-turbo/Makefile.in
  	$(srcdir)/jconfigint.h.in $(srcdir)/libjpeg.map.in \
 @@ -622,7 +622,7 @@
  	jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \
- 	jquant2.c jutils.c jmemmgr.c jmemnobs.c $(am__append_3) \
- 	$(am__append_4) $(am__append_5) $(am__append_10)
--SUBDIRS = java $(am__append_9) md5
-+SUBDIRS = java $(am__append_9)
+ 	jquant2.c jutils.c jmemmgr.c jmemnobs.c $(am__append_4) \
+ 	$(am__append_5) $(am__append_6) $(am__append_11)
+-SUBDIRS = java $(am__append_10) md5
++SUBDIRS = java $(am__append_10)
  @WITH_TURBOJPEG_TRUE at libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) \
  @WITH_TURBOJPEG_TRUE@	turbojpeg.c turbojpeg.h transupp.c \
  @WITH_TURBOJPEG_TRUE@	transupp.h jdatadst-tj.c jdatasrc-tj.c \
diff --git a/external/jpeg-turbo/jpeg-turbo.win_build.patch.1 b/external/jpeg-turbo/jpeg-turbo.win_build.patch.1
index b5dabaa53ade..00b642703f3a 100644
--- a/external/jpeg-turbo/jpeg-turbo.win_build.patch.1
+++ b/external/jpeg-turbo/jpeg-turbo.win_build.patch.1
@@ -32,8 +32,8 @@ diff -ru jpeg-turbo.orig/configure jpeg-turbo/configure
 +++ jpeg-turbo/jconfig.h.in	2016-11-02 22:45:01.905400000 +0100
 @@ -71,3 +71,21 @@
  
- /* The size of `size_t', as computed by sizeof. */
- #undef SIZEOF_SIZE_T
+ /* Define to `unsigned int' if <sys/types.h> does not define. */
+ #undef size_t
 +
 +#ifdef _MSC_VER
 +
diff --git a/external/jpeg-turbo/ubsan.patch b/external/jpeg-turbo/ubsan.patch
index 81ff148c57d6..33d3c15a8b3c 100644
--- a/external/jpeg-turbo/ubsan.patch
+++ b/external/jpeg-turbo/ubsan.patch
@@ -17,3 +17,23 @@
      put_bits -= 8;
    }
  
+--- jdarith.c
++++ jdarith.c
+@@ -306,7 +306,7 @@
+       while (m >>= 1)
+         if (arith_decode(cinfo, st)) v |= m;
+       v += 1; if (sign) v = -v;
+-      entropy->last_dc_val[ci] += v;
++      entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
+     }
+ 
+     /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
+@@ -564,7 +564,7 @@
+       while (m >>= 1)
+         if (arith_decode(cinfo, st)) v |= m;
+       v += 1; if (sign) v = -v;
+-      entropy->last_dc_val[ci] += v;
++      entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
+     }
+ 
+     if (block)


More information about the Libreoffice-commits mailing list