Commit Graph
2065 Commits
Author SHA1 Message Date
Caolán McNamara f30bc3ccdf use internal SHA256Thumbprint api
Change-Id: I6a51359af58dbb79b6a0399944030dbcbe97152b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130963
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-03-04 14:26:04 +01:00
Caolán McNamara 65442205b5 compare authors using Thumbprint
Change-Id: I338f58eb07cbf0a3d13a7dafdaddac09252a8546
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130929
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-03-04 08:31:12 +01:00
Hossein 02e1be8883 Cleanup x509certificate_nssimpl.cxx
* Remove unused headers
* Remove 'using namespace'
* Use enum values in the condition

Change-Id: I45c20412db48ed1a3a4471db20193c2d9cde2f94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130214
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-21 20:55:45 +01:00
Caolán McNamara e00032ba6a add toId/fromId to tidy up some ugly casting
Change-Id: I70f34ac5e9b5d2f2d6c0375e823908eaa2e540b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129487
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-02-04 15:02:03 +01:00
Szymon Kłos 1da258a626 Make Certificate not found dialog async
Change-Id: I8da2a2dc763cffd13659b61966a954a6e1ef06a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124269
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128841
Tested-by: Jenkins
2022-01-24 13:46:57 +01:00
Szymon Kłos 98d2c965ac Make View Certificate sub-dialog async
Change-Id: I0e1a6a59d856ab266511fc3d6be87fe04c5afdfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124143
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128840
Tested-by: Jenkins
2022-01-24 13:46:42 +01:00
Szymon Kłos c13ec26f6a Make View Certificate dialog async
Change-Id: Id93145ecf6be3cb558f0ce8d3cc340bbc67095e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124061
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128839
Tested-by: Jenkins
2022-01-24 09:44:19 +01:00
Szymon Kłos 71a8bad4b9 jsdialog: enable Digital Signatures dialog
In LOK case run it in the readonly mode.
In readonly mode we can run it asynchronously.

Change-Id: I721dd14fa23d4e30255dd976e0cc2a4f30470a3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124058
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128838
Tested-by: Jenkins
2022-01-24 09:43:53 +01:00
scito 67fb363eed tdf#146392 fix --enable-pch=full build
x509.h includes cert.h. But that doesn't know of LO using
xmlsecurity/source/xmlsec/nss/nssrenam.h, which has a "#define
CERT_DecodeDERCertificate __CERT_DecodeDERCertificate". So the PCH
doesn't know of this rename and the compiler fails.

move the include line into the file that needs it and the --enable-pch=full
build works ok

Change-Id: I247bd219cf47964490ded439ad51bd8e8e120c48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127744
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Jenkins
2022-01-06 17:34:05 +01:00
Miklos Vajna 9fb45044d9 xmlsecurity nss: log what XML DOM node is given to libxmlsec
We have two environments where the signature and the stream bytes are
the same, still in one case the signature verification succeeds and in
the other case the hash doesn't match.

Log the signature as parsed into a DOM node (recursively), just case
something goes wrong during extracting a single signature from the
signatures list XML.

Change-Id: I54af71fdeb63d8ef44342f106746f938fa51f29a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127991
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2022-01-05 12:24:03 +01:00
Thorsten Behrens 78dae8b20b Update gpgme to 1.16.0
* remove GPGME_CAN_EXPORT_MINIMAL_KEY, upstream now has support for
  key export flags in c++ wrapper (gpgmepp >= 1.14)
* therefore, external/gpgmepp/add-minimal-keyexport.patch now fully
  obsolete, tweaked xmlsecurity code to use upstream function
* bits of external/gpgmepp/find-libgpg-error-libassuan.patch are
  upstream now (configure and makefile pieces, though we keep
  configure.ac changes for the while - to not pick up system versions
  too easily)
* external/gpgmepp/gpgme.git-fe2892618c20cd40c342cce26ffb6ac4644fd3c3.patch.1
  was from upstream anyway, removed

Change-Id: I991c20c0eeff0f9135e97c991afcb905be55a959
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127665
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2022-01-05 09:53:07 +01:00
Miklos Vajna b737cf89a3 xmlsecurity: log the signature we read from the ZIP package
We can already see if a signature verification fails and what is the
content of the ZIP streams we hash.

Show what is the expected hash as well.

Change-Id: Ibc67b7de0e8d03e06da1b86b6e8a7b2b2e613882
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127934
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2022-01-04 12:22:12 +01:00
Miklos Vajna 7d90a00a49 xmlsecurity: add some more logging
We only get:

warn:xmlsecurity.xmlsec:32272:32272:xmlsecurity/source/xmlsec/errorcallback.cxx:53: digests.c:226: xmlSecNssDigestVerify() 'sha1' '' 12 'data and digest do not match'

when one of the XML streams have a bad hash. Add some logging to help
figuring out (without a debugger) which stream is at fault.

Change-Id: Ib5f39df87bcdaaac1a21eb560c8f775c42a4079f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127885
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2022-01-03 14:42:24 +01:00
Mike Kaganski 9c95415de8 Let comphelper::Base64::decode* take std::u16string_view
Change-Id: I5b04f7adf11c61f52b7bfb0f52c8c075f838f0f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127480
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-12-26 23:09:20 +01:00
Noel Grandin b0163975ef osl::Mutex->std::mutex in OCipherContext
Change-Id: I0a457dc8ddccc0fce42032956aff6d661d1ae80a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127403
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-12-24 14:45:11 +01:00
Caolán McNamara be446d81e0 only use X509Data
Change-Id: I52e6588f5fac04bb26d77c1f3af470db73e41f72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127193
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-12-21 08:37:45 +01:00
Noel Grandin 6da12ca82d loplugin:stringliteraldefine in various
Change-Id: Ib482e3982128dc47d88a79478d80eef43745d1b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126086
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-30 14:07:26 +01:00
Tomaž Vajngerl f2e1e4ff08 xmlsec: fix OOXML signing with multiple certs, extend the test
Signing OOXML with 3 or more times didn't work as other ids
("idPackageObject", "idOfficeObject", ...) were not uniqe. This
change makes those ids unique by appending the signature id. The
signature ID is now generated for OOXML too, while previously it
was a hardcoded string ("idPackageSignature").

The test for signing multiple OOXML was written before, but didn't
catch the issues because it didn't assert the status of the
document after loading it again. This is which is now fixed (and
also added changed for the ODF test case).

Change-Id: Ifa20ea17498b117a4c57f6eddf82f8e83bc640bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124571
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2021-11-02 14:05:50 +01:00
Stephan Bergmann 7d936a98cd Fix more misuses of NULL across Windows-only code
...that had inadvertently been missing from
a5cea74034 °Fix misuses of NULL across
Windows-only code"

Change-Id: I8f60cd6114ceb7c6413fb099778bfb06407bbb24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124431
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-11-01 09:57:13 +01:00
Mike Kaganski d12f25905c Prepare for removal of non-const operator[] from Sequence in xmlsecurity
Change-Id: I7cfcf9f9ea307bd737292e6f4f37a29f453167c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124418
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-11-01 09:55:03 +01:00
Stephan Bergmann dfdb04938f loplugin:simplifybool (clang-cl)
(not a typo according to the comment at
<https://gerrit.libreoffice.org/c/core/+/124287/3#message-df56362ec7d674eaab3fe81bb0827be81ee5686d>
"xmlsecurity: some Distinguished Names are less equal than others":  "i was too
lazy to look up which integer would be returned by the function and hoped this
would convert it to bool anyway"

Change-Id: I0f4f4d19e8d382f4430023aa6f9459c66a605b04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124321
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-10-28 14:34:54 +02:00
Tomaž Vajngerl fd5463343a xmlsec: signing the document fails the 3rd time (invalid signature)
Signing the document 3 or more times produces an invalid signature.
The cause of this is that xmlsec is confused because we have 3
signatures, which all have the same SignedProperties with the ID
"idSignedProperties", but it expect them to be unique.

This issue is fixed by making the ID unique with adding the ID of
the Signature to the SignedProperties ID, so this makes them unique
inside the same Signature.

Also UnsignedProperties have a unique ID usign the same approach,
but they aren't referenced - luckily.

Change-Id: I53c7249a82fc0623586548db9fa25bdc0e7c4101
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124278
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2021-10-28 08:49:57 +02:00
Michael Stahl e63611fabd xmlsecurity: some Distinguished Names are less equal than others
It turns out that the 2 backends NSS and MS CryptoAPI generate different
string representations of the same Distinguished Name in at least one
corner case, when a value contains a quote " U+0022.

The CryptoAPI function to generate the strings is:
CertNameToStr(..., CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, ...)

This is documented on MSDN:
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certnametostra#CERT_X500_NAME_STR

NSS appears to implement RFC 1485, at least that's what the internal
function is named after, or perhaps one of its several successor RFCs
(not clear currently if there's a relevant difference).

This is now causing trouble if a certificate with such a DN is used in a
signature, created on WNT but then verified on another platform, because
commit 5af5ea893b
introduced consistency checks that compare the DNs that occur as strings
in META-INF/documentsignatures.xml:

xmlsecurity/source/helper/xmlsignaturehelper.cxx:672: X509Data cannot be parsed

The reason is that in XSecController::setX509Data() the value read from
the X509IssuerSerial element (a string generated by CryptoAPI) doesn't
match the value generated by NSS from the certificate parsed from the
X509Certificate element, so these are erroneously interpreted as 2
distinct certificates.

Try to make the EqualDistinguishedNames() more flexible so that it can
try also a converted variant of the DN.

(libxmlsec's NSS backend also complains that it cannot parse the DN:
 x509vfy.c:607: xmlSecNssX509NameRead() '' '' 12 'invalid data for 'char': actual=34 and expected comma ',''
 but it manages to validate the signature despite this.)

Change-Id: I4f72900738d1f5313146bbda7320a8f44319ebc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124287
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-10-27 20:35:31 +02:00
Szymon Kłos 97b15bcc2d tdf#145312 xmlsecurity: prevent from crash when cannot receive pdfium annotation
Change-Id: I6adc2cb0a07eb08a50c610958983493f4f8031ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124021
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2021-10-25 14:04:56 +02:00
Noel Grandin 29489b33b4 loplugin:flatten
Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-21 14:58:51 +02:00
Stephan Bergmann 4fcb64b79f loplugin various (clang-cl)
Change-Id: Ib9bd9b96d28c9c4dd0fa36a82a177e119aa04e6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123820
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-10-19 19:57:34 +02:00
Michael Stahl 7d664ec788 xmlsecurity: fix new tests on WNT
Tests added in commit 40d70d427e don't
actually run on WNT but that wasn't obvious because commit
149df1fec6 prevented running them in
Jenkins on master, they failed only in the libreoffice-7-1 backport.

  xmlsecurity/qa/unit/signing/signing.cxx(631) : error : Assertion
  Test name: testODFDoubleX509Certificate::TestBody
  assertion failed
  - Expression: (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)
  - 2

This is an oddity where NSS claims the signature in the document is
valid but CryptoAPI claims it is invalid; the hashes passed into the
validation functions are the same.  Just allow BROKEN as an additional
result value on WNT.

  xmlsecurity/qa/unit/signing/signing.cxx(550) : error : Assertion
  Test name: testODFX509CertificateChain::TestBody
  equality assertion failed
  - Expected: 0
  - Actual  : 1

The problem here is that with NSS the tests use a custom NSS database
in test/signing-keys so we need to make these certificates available for
CryptoAPI too.

The following one-liner converts the NSS database to a PKCS#7 that can
be loaded by CrytpAPI:

> openssl crl2pkcs7 -nocrl -certfile <(certutil -d sql:test/signing-keys -L | awk '/^[^ ].*,[^ ]*,/ { printf "%s", $1; for (i = 2; i < NF; i++) { printf " %s", $i; } printf "\n"; }' | while read name; do certutil -L -d sql:test/signing-keys -a -n "${name}" ; done) > test/signing-keys/test.p7b

Then one might naively assume that something like this would allow these
certificates to be added temporarily as trusted CAs:

+                HCERTSTORE hRoot = CertOpenSystemStoreW( 0, L"Root" ) ;
+                HCERTSTORE const hExtra = CertOpenStore(
+                        CERT_STORE_PROV_FILENAME_A,
+                        PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
+                        NULL,
+                        CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG,
+                        path);
+                if (hExtra != NULL && hRoot != NULL)
+                {
+                    BOOL ret = CertAddStoreToCollection(
+                        hRoot,
+                        hExtra,
+                        CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG,
+                        0);
+                    SAL_DEBUG("XXX hExtra done " << ret);
+                }

There is no error from this, but it doesn't work.

Instead, check if CertGetCertificateChain() sets the
CERT_TRUST_IS_UNTRUSTED_ROOT flag and then look up the certificate
manually in the extra PKCS#7 store.

Change-Id: Ic9865e0b5783211c2128ce0327c4583b7784ff62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123667
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-10-18 08:28:25 +02:00
Michael Stahl d06f8ba07a xmlsecurity: fix some obvious copypasta
These 2 calls to CertAddStoreToCollection follow calls where
m_hCertStore was already added and according to the comments they
should add the other store instead.

(regression from commit 813e1f5a8a)

Change-Id: If375f603647a702feb0ca8f272126a15d5d0e906
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123666
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-10-18 08:23:45 +02:00
Julien Nabet 1d1d0bd4d9 Simplify Sequences in xmlsecurity
Change-Id: I749e19f786ad006dffcd65dd1ee60e57c428f57b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123717
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-10-17 17:21:34 +02:00
Julien Nabet 4af72419f3 Simplify vector initialization in xmlsecurity
Change-Id: Ia19ffa1213d578c30f35545bcca515669e7ff7a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123710
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-10-17 12:30:15 +02:00
Mike Kaganski 8a017d25a6 Avoid COW overhead using css::uno::Sequence
The scenarios are:

1. Calling sequence's begin() and end() in pairs to pass to algorithms
   (both calls use getArray(), which does the COW checks)
2. In addition to #1, calling end() again when checking result of find
   algorithms, and/or begin() to calculate result's distance
3. Using non-const sequences in range-based for loops, which internally
   do #1
4. Assigning sequence to another sequence variable, and then modifying
   one of them

In many cases, the sequences could be made const, or treated as const
for the purposes of the algorithms (using std::as_const, std::cbegin,
and std::cend). Where algorithm modifies the sequence, it was changed
to only call getArray() once. For that, css::uno::toNonConstRange was
introduced, which returns a struct (sublclass of std::pair) with two
iterators [begin, end], that are calculated using one call to begin()
and one call to getLength().

To handle #4, css::uno::Sequence::swap was introduced, that swaps the
internal pointer to uno_Sequence. So when a local Sequence variable
should be assigned to another variable, and the latter will be modified
further, it's now possible to use swap instead, so the two sequences
are kept independent.

The modified places were found by temporarily removing non-const end().

Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-14 06:00:49 +02:00
Noel Grandin 13fa6834c9 loplugin:moveparam in xmlsecurity
Change-Id: I3ce77ab82529f13c5e55ea30c813f66cb5180877
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123369
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-11 12:58:41 +02:00
Noel Grandin 64937ff98a loplugin:moveparam in unotools
Change-Id: Idd014c93e2e85d2ffc7a2535a9c65cffc8a9d403
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123348
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-11 10:39:38 +02:00
Noel Grandin 5cd87f1956 loplugin:moveparam in vcl
Change-Id: I6dea009e1031174ecb3d4371e91c9c6d26c6e514
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123245
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-08 17:10:27 +02:00
Stephan Bergmann ad1557f5d7 A more lightweight O[U]StringConcatenation
...compared to a full-blown O[U]String, for temporary objects holding an
O[U]StringConcat result that can then be used as a std::[u16]string_view.

It's instructive to see how some invocations of operator ==, operator !=, and
O[U]StringBuffer::insert with an O[U]StringConcat argument required implicit
materialization of an O[U]String temporary, and how that expensive operation has
now been made explicit with the explicit O[U]StringConcatenation ctor.

(The additional operator == and operator != overloads are necessary because the
overloads taking two std::[u16]string_view parameters wouldn't even be found
here with ADL.  And the OUString-related ones would cause ambiguities in at
least sal/qa/rtl/strings/test_oustring_stringliterals.cxx built with
RTL_STRING_UNITTEST, so have simply been disabled for that special test-code
case.)

Change-Id: Id29799fa8da21a09ff9794cbc7cc9b366e6803b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122890
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-10-03 19:50:44 +02:00
Stephan Bergmann 924e0774a8 Extend loplugin:stringviewparam to starts/endsWith: xmlsecurity
Change-Id: I8a08b0382121355c70284c2e85375ba6c3671553
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122468
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-09-22 19:58:55 +02:00
Noel Grandin 3a1a448ac4 loplugin:constvars
Change-Id: I9b35d6333afa6b305bf73fc55a7e60c8365674e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122134
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-15 12:43:21 +02:00
Mike Kaganski 96bd77de5a Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 5
- Revise uses of getSomething to use getFromUnoTunnel

Where that is impossible, use getSomething_cast to unify casting,
and minimize number of places doing low-level transformations.

The change keeps the existing tunnel references that last for the
duration of the pointers' life, because sometimes destroying such
reference may destroy the pointed object, and result in use after
free.

Change-Id: I291c33223582c34cd2c763aa8aacf0ae899ca4c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122101
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-15 06:08:27 +02:00
Mike Kaganski 3f65724ec5 Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 4
- Change implementations of getSomething to use getSomethingImpl

Or where that's impossible, use getSomething_cast to unify this and
reduce number of places where we reinterpret_cast.

All static methods getting tunnel ids were renamed to getUnoTunnelId,
to comply with the convention used in <comphelper/servicehelper.hxx>.

TODO (in separate commits):
- Revise uses of getSomething to use getFromUnoTunnel

Change-Id: Ifde9e214b52e5df678de71fcc32d2199c82e85cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122100
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-15 06:08:14 +02:00
Mike Kaganski 6444b026b4 Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 3 [API CHANGE]
- Replace all uses of OImplementationId in core with UnoIdInit
- Deprecate OImplementationId in <cppuhelper/typeprovider.hxx>

OImplementationId uses broken double checked locking; additionally,
it uses it at the first call to getImplementationId, not when the
object is constructed. This implementation can't be changed, cince
it's part of published API; it can't rely on C++11, which would be
required for use of thread-safe statics and move the initialization
to ctor.

The class has obsolete _bUseEthernetAddress member, that is unused
and ignored since 4e9fa7e339. No need
to implement it when replacing its uses to UnoIdInit.

The deprecation is the API CHANGE. No published API is introduced to
replace it; 3rd-party code should seek alternative solutions, or just
keep using the deprecated functionality.

TODO (in separate commits):
- Change implementations of getSomething to use getSomethingImpl
- Revise uses of getSomething to use getFromUnoTunnel

Change-Id: I8b6e684e5389bc0d5bb3b7f21f72a4c8f684107d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122077
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-15 06:08:01 +02:00
Mike Kaganski 05bc93db2d Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 1
The header got some changes:
1. Move UnoTunnelIdInit and isUnoTunnelId into 'comphelper' namespace
2. Rename UnoTunnelIdInit to UnoIdInit, as a precondition to replace
   of uses of OImplementationId with it, including in XTypeProvider
3. Introduce convenience functions 'getSomething_cast' to cast between
   sal_Int64 and object pointers uniformly.
4. Rename getUnoTunnelImplementation to getFromUnoTunnel, both to make
   it a bit shorter, and to reflect its function better. Templatize it
   to take also css::uno::Any for convenience.
5. Introduce getSomethingImpl, inspired by sw::UnoTunnelImpl; allow it
   handle cases both with and without fallback to parent.
6. Adjust UNO3_GETIMPLEMENTATION_* macros

TODO (in separate commits):
- Drop sw::UnoTunnelImpl and sw::UnoTunnelGetImplementation
- Replace all uses of OImplementationId in core with UnoIdInit
- Deprecate OImplementationId in <cppuhelper/typeprovider.hxx>
- Change implementations of getSomething to use getSomethingImpl
- Revise uses of getSomething to use getFromUnoTunnel

Change-Id: If4a3cb024130f1f552f988f0479589da1cd066e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122022
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-15 06:07:36 +02:00
Noel Grandin 6cc1ee9035 clang-tidy:readability-redundant-member-init
Change-Id: Iede70151af052505b780c6ce708aa74d97da5c75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121545
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-03 12:44:22 +02:00
Noel Grandin 8a54339fc8 loplugin:referencecasting look through more clang Types
Note that because of where the fix resides, loplugin:redundantcast
also notices a few more things.

Change-Id: I0b66047fadfff2c5ceafcbd3eab085de00d861a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120865
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-23 15:25:26 +02:00
Noel Grandin 18f2020116 loplugin:constparams
Change-Id: Ic7410f836e584df45101e78e345c8b3c8d355e09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120680
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-18 21:18:29 +02:00
Stephan Bergmann 43542cc07e Missing include
(for std::unique_ptr, with recent libstdc++ 12 trunk)

Change-Id: I61b7823dd740ea7cdfe0d7403a50ac73b24d1c4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120229
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-08-10 07:39:00 +02:00
Noel Grandin 14cfff500e Pass context and resource string down to boost::locale separately
because this is often on a hot path, and we can avoid the splitting and
joining of strings like this.

Change-Id: Ia36047209368ca53431178c2e8723a18cfe8260a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119220
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-05 09:39:11 +02:00
Noel Grandin 05ab38359a Consolidate on C++17 std::scoped_lock instead of std::lock_guard
as in commit 9376f65a26

Change-Id: I3ad9afd4d113582a214a4a4bc7eea55e38cd6ff9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119927
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-03 12:20:53 +02:00
Noel Grandin 1597cc5b3e convert #defines to OUStringLiteral
mostly by doing

$ git grep -l '#define.*\"' -- *.cxx
    | xargs perl -pi -e
's/^#define\s+(\w+)\s+(\".*\")/constexpr OUStringLiteral \1 =
u\2;/g'

Change-Id: Idface893449b0ef2a3c5254865a300585d752fbb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119669
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-02 14:43:58 +02:00
Noel Grandin e5982d9148 osl::Mutex->std::mutex in ODigestContext
Change-Id: I168750490f2c60f8c93aef630949acb4e29734b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119750
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-01 13:57:55 +02:00
Noel Grandin 5b5d3d90f3 osl::Mutex->std::mutex in SecurityEnvironment_NssImpl
Change-Id: I4b00afbe71b5459a9b1b8e612e44af71616a9b8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119749
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-01 12:41:02 +02:00