Commit Graph
502 Commits
Author SHA1 Message Date
Mike Kaganski a53f0dc811 Extract Local file header and Data descriptor handling into own functions
Change-Id: I16405f13298934945cc1d5d4a50d403b37c3234e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162912
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-02 07:27:29 +01:00
Mike Kaganski 747463809e tdf#154587: allow directory entries in ZIP packages
The problem in the bugdoc was the directory entries. These entries
are valid in ZIP packages (even if not common); they may be useful
to e.g. define per-directory permissions (ACLs).

In normal mode, ZipFile reads central directory; there we can read
if the entry has FAT file attributes; and then, if the entry is a
directory. Then it is OK to skip it.

In repair mode, central directory is not used, local file headers
don't contain a "directory" flag. A workaround is used, checking
if there are entries that represent directories of other entries.

Also this change fixes some places that didn't pass the recovery
flag correctly.

Change-Id: I324671841a2c4d0f279b03801d95c8f2eeb99b46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162888
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-01 21:07:54 +01:00
Caolán McNamara 69181dd430 ofz#65480: Integer-overflow
Change-Id: Ie771e6e37237907698e4c39eb50cd940500b86ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161540
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-01-02 20:15:00 +01:00
Caolán McNamara 6ef28599b2 cid#1545612 COPY_INSTEAD_OF_MOVE
and

cid#1545605 COPY_INSTEAD_OF_MOVE
cid#1545587 COPY_INSTEAD_OF_MOVE

Change-Id: Iafb1d81dbacfefe70fbddd84b29e827dc137ef07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161077
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-20 20:59:04 +01:00
Michael Stahl 2f512aaa6c tdf#105844 offapi,package,sfx2: use Argon2 for wholesome ODF encryption
https://www.rfc-editor.org/rfc/rfc9106.html

* add css::xml::crypto::KDFID constant group
* add "KeyDerivationFunction" to setEncryptionAlgorithms sequence
* Argon2 is used by default for wholesome ODF encryption, but
  $LO_ARGON2_DISABLE can be set to use PBKDF2
* extend various structs in package
* use 3 new ODF attributes "loext:argon2-iterations" "loext:argon2-memory"
  "loext:argon2-lanes" to store the arguments
* use this URL for now:
  "urn:org:documentfoundation:names:experimental:office:manifest:argon2id"
* use default arguments according to second recommendation from "7.4.
  Recommendations" of RFC9106; 64 MiB RAM should hopefully not be too
  much even for 32 bit builds

Change-Id: I683118cc5e0706bd6544db6fb909096768ac9920
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161009
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-12-20 18:29:36 +01:00
Michael Stahl 91f35f22f0 tdf#105844 package: remove root document from manifest ...
... for ODF wholesome encryption.

  4.3  <manifest:file-entry>
  For directories, the manifest file should contain a <manifest:file-entry> element only if a directory contains a document or a sub document.

Because the "encrypted-package" is not a document but a package, we
should probably omit the file-entry for the root document.

ZipPackage::writeTempFile() always generates the root document becuase
it's needed for GPG properties, and ManifestExport filters it out.

A bit tricky to implement, because there isn't a clean distinction
between the package and the root document/storage in the package module,
in particular there's no other place than the root storage to store the
MediaType property.

Change-Id: Id7e72a64e2faa074dce80cd5fefb2fa189e2e3ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160717
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-12-14 15:38:13 +01:00
Michael Stahl 09f23a3dc5 tdf#105844 package,sfx2: remove checksum infoleak when using AEAD
AEAD provides the verification of the password automatically, by reading
the entire stream the tag at the end will be verified.

The existing attributes manifest:checksum-type/manifest:checksum leak
information about the plain text.

This was mitigated with the addChaffWhenEncryptedStorage() functions
(see commit f57baefbd3) but a better
solution that also works for non-XML streams is to simply omit the
attributes; authenticated encryption provides better verification
without any leak.

* "ChecksumAlgorithm" property can be set to void now to remove the
  checksum
* change a bunch of members in EncryptionData, ZipPackage,
  ZipPackageStream to optional
* change ZipFile::checkValidPassword() to open the stream and return it

Change-Id: Id95288d0c238c4f9940fc5a185df814e8edcbad3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160711
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-12-13 22:02:52 +01:00
Michael Stahl 6e3a6ca050 package: move function down
Change-Id: I92742a28cf60a9dfc80001f9ca3c5551fe94472d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160677
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-12-13 16:51:28 +01:00
Michael Stahl f0fda7ad22 tdf#105844 offapi,package,sfx2,xmlsecurity: add AEAD w/ AES GCM
... and use it in the new experimental ODF encryption mode.

https://www.w3.org/TR/xmlenc-core1/#sec-AES-GCM

Unfortunately it turned out that NSS PK11_CipherOp() does not work with
CKM_AES_GCM because it is initialized with "context->multi = PR_FALSE"
in sftk_CryptInit(), so the one-step functions PK11_Encrypt() and
PK11_Decrypt() have to be used.

NSS 3.52 also changed a parameter struct definition - see
https://fedoraproject.org/wiki/Changes/NssGCMParams - which is not a
problem for RHEL or SUSE system NSS since those are rebased, but it
is likely a problem for less well maintained Ubuntu LTS, so use
the old struct definition which evidently still works with NSS 3.94.

NSS 3.52 also added a new PK11_AEADOp() API but it looks like this
doesn't support incremental encryption either.

Change-Id: Ibd4a672db74b65b1218926ba35ff8d2f70444c7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160505
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-12-11 20:46:40 +01:00
Noel Grandin 8270eb5d56 loplugin:unusedmethods
Change-Id: Ief95f111350808f010539bb733a553007d30a9df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152006
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-20 12:55:07 +02:00
Caolán McNamara e7c30e6c1e Resolves: tdf#155005 use of uninitialised value
==2515797== Conditional jump or move depends on uninitialised value(s)
==2515797==    at 0x33FAB399: ZipFile::recover() (ZipFile.cxx:1090)
==2515797==    by 0x33FA4D32: ZipFile::ZipFile(rtl::Reference<comphelper::RefCountedMutex>, com::sun::star::uno::Reference<com::sun::star::io::XInputStream> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>, bool, bool) (ZipFile.cxx:111)
==2515797==    by 0x33FEF134: void std::_Construct<ZipFile, rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, bool&>(ZipFile*, rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool&&, bool&) (stl_construct.h:119)
==2515797==    by 0x33FED528: void std::_Optional_payload_base<ZipFile>::_M_construct<rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, bool&>(rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool&&, bool&) (optional:278)
==2515797==    by 0x33FEB73B: void std::_Optional_base_impl<ZipFile, std::_Optional_base<ZipFile, false, false> >::_M_construct<rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, bool&>(rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool&&, bool&) (optional:457)
==2515797==    by 0x33FE77DB: std::enable_if<is_constructible_v<ZipFile, rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, bool&>, ZipFile&>::type std::optional<ZipFile>::emplace<rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, bool&>(rtl::Reference<comphelper::RefCountedMutex>&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool&&, bool&) (optional:918)
==2515797==    by 0x33FD61FD: ZipPackage::initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (ZipPackage.cxx:760)
==2515797==    by 0x64DE1EC: cppuhelper::ServiceManager::Data::Implementation::doCreateInstanceWithArguments(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (servicemanager.cxx:732)
==2515797==    by 0x64DDF19: cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (servicemanager.cxx:694)
==2515797==    by 0x64E0E8F: cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (servicemanager.cxx:1018)
==2515797==    by 0x34A3B25F: OStorage_Impl::OpenOwnPackage() (xstorage.cxx:435)
==2515797==    by 0x34A3C16C: OStorage_Impl::ReadContents() (xstorage.cxx:541)
==2515797==  Uninitialised value was created by a stack allocation
==2515797==    at 0x33FAB02C: ZipFile::recover() (ZipFile.cxx:1034)

since:

    commit abda72eeac
    Date:   Mon Feb 20 00:32:22 2023 +0100

        tdf#82984 tdf#94915 zip64 support (import + export)

where

- aEntry.nCompressedSize = nCompressedSize;
- aEntry.nSize = nSize;

was removed before the subsequent use of aEntry.nCompressedSize/aEntry.nSize

change things (git show -w for clarity) to check bounds first just for
the range the extra fields might be in and read those, and then follow
up with the original check that the newly discovered
aEntry.nCompressedSize/aEntry.nSize are within the bounds of the overall
file

Change-Id: Iad4ce8297109b06bc5baf77df4f3e86659cbb4cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150969
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-04-25 15:10:35 +02:00
Caolán McNamara 80805716a4 tdf#155005 fail gracefully on encountering a negative compression value
we are using sal_Int64 for this so a large enough value can be
interpreted as negative here

Change-Id: Id547a24591aca4b6ed7b7955621641a0666b0bd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150968
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-04-25 15:10:15 +02:00
Caolán McNamara 397e2d5118 ofz#57529 Integer-overflow
Change-Id: I93775299aa340e2e645a04be5d0bc36a9caea103
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149773
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-03-30 22:02:08 +00:00
Stephan Bergmann 7cce1141c6 Missing includes (for std::exception_ptr)
Change-Id: If93883ba9feb22e6da2d56af4ebb2f4eafe58de1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149162
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-20 15:21:08 +00:00
Caolán McNamara b6d1cb8874 cid#1521901 Pointer to local outside scope
Change-Id: I38e76440606afb65a8c1ce419c446e234a513659
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148550
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-03-09 20:17:15 +00:00
Caolán McNamara 59b0f67675 ofz#56826 Heap-use-after-free
since:

commit abda72eeac
Date:   Mon Feb 20 00:32:22 2023 +0100

    tdf#82984 tdf#94915 zip64 support (import + export)

Change-Id: Iffc1c54b3ccc5464e217d7f94ecc34b57ec1afb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148526
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-03-09 10:18:42 +00:00
Andrea Gelmini 5eae429d02 Fix typo
Change-Id: I4c48c988667ffd9221a0e226ab9c35e1e857e9d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148489
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-03-09 06:20:54 +00:00
Attila Szűcs abda72eeac tdf#82984 tdf#94915 zip64 support (import + export)
Implemented import + export for "Zip64 Extended Information Extra Field",
(in "Local file header" and "Central directory file header")
and for Data descriptor.
Focused only to be able to handle files with over 4GB uncompressed size,
in the zip archive.
The 64k filecount, and the 4GB compressed size limit is probably still present

Tried to follow pkware .ZIP File Format Specification,
Some cases were not clear to me and/or some zip compressing tool may not
perfectly follow the standard, like 'extra field' should be 28 bytes long,
but its reader now can read shorter (or longer) 'extra field'.

Replaced some 32bit codes with 64bit codes, in stream handling, in deflater.

Tested with an ods file that contained a content.xml that bigger then 4BG+
(import + export + reimport) on windows.
I think 4GB+ files import/export would be too slow fot unittest.
So, for unit test, used the small but zip64 format files,
that was attached to the bugzilla tickets

Note: It helps with Bug 128244 too (1 of the unittest tests it),
but that ods file missing manifest.xml, so LO won't be able to import it.

Change-Id: Idfeb90594388fd34ae719677f5d268ca9a484fb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147306
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2023-03-08 14:53:57 +00:00
Noel Grandin a04bf69bcc XUnoTunnel->dynamic_cast in ZipPackageEntry
Change-Id: I0c49ebcb0ed16ab5b90c0cfa1417f002b5dad7b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145632
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-17 19:09:51 +00:00
Mike Kaganski 3de6b42235 Simplify a bit
Change-Id: Ie2435701078b0e111c1b04b77c857fd1923f2d59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145430
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-01-13 09:22:34 +00:00
Noel Grandin 14df26ac57 XUnoTunnel->dynamic_cast in comphelper::ByteReader and comphelper::ByteWriter
Change-Id: I1f8c864a939dff1252ba15f517f63b62d1a1e1fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145393
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-13 06:15:21 +00:00
Arnaud VERSINI 555f433318 use std::this_thread::sleep_for instead of osl equivalent
Change-Id: I5b4edc5417e5bb5e082688df616e1d5735717d92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142357
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-09 08:37:35 +00:00
Caolán McNamara fb1bf9f1fd cid#1242675 Untrusted value as argument
Change-Id: If8ecad4501d6c555791eae0ae113a34e05f9436f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141670
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-10-27 09:47:54 +02:00
Noel Grandin 848f9b2c56 tdf#133767 new service TempFileFastService
to use in places where we know we can use the TempFileFast mechanism.

Speeds up export to EPUB from 43s to 17s on my windows machine.

This is essentially a copy of OTempFileService, but it does not
implement XTempFile (because these temp files have no name on Windows).

Also remove a couple of calls to Flush() (which is not necessary now),
and TellEnd(), which is a little slow on Windows.

Change-Id: Iced300bf8121eae08c7a011d62ec68b93330d84c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141598
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-21 12:01:05 +02:00
Stephan Bergmann 91ba9654ba Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxx
...so that its TOOLS_WARN_EXCEPTION can be used in
comphelper/source/misc/logging.cxx in a follow-up commit.  (And while at it,
rename from diangose_ex.h to the more appropriate diagnose_ex.hxx.  The
comphelper module is sufficiently low-level for this immediate use case, so use
that at least for now; o3tl might be even more suitable but doesn't have a
Library until now.  Also, for the immediate use case it would have sufficed to
only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION,
TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of
include/tools/diagnose_ex.h into an additional new
include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move
the complete include file as is.)

Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-18 17:10:19 +02:00
Noel Grandin 74ff1a4355 clang-tidy modernize-pass-by-value in package
Change-Id: Id12d7b38d278c9fb18b30c6d921713a53168b048
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136337
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-06-23 18:24:16 +02:00
Stephan Bergmann b4163877e7 Use more appropriate return type for ThreadPool::getPreferredConcurrency
All call sites already effectively asked for an unsigned return type, including:
* The ThreadPool ctor took an nWorkers argument of type sal_Int32, but
  internally stores that as std::size_t mnMaxWorkers.
* ZipOutputStream::reduceScheduledThreadTasksToGivenNumberOrLess apparently
  benefits from an unsigned nThreadTasks parameter, getting rid of various casts
  in its implementation that were necessary to silence signed vs. unsigned
  comparison warnings.

The only drawback is that

  comphelper::ThreadPool::getPreferredConcurrency() * 4

in package/source/zippackage/ZipPackageStream.cxx would now silently wrap around
instead of causing UB on overflow (which could be detected with appropriate
tools).  Ideally, it would use some o3tl::saturating_mul if we had that, so add
a TODO comment for now.

While std::thread::hardware_concurrency returns unsigned, it looked more natural
to go with std::size_t here, as some call sites already used that (see above),
so the implementation of ThreadPool::getPreferredConcurrency is a natural place
to hide clamping std::thread::hardware_concurrency() to std::size_t (in the
unlikely case that std::size_t is of smaller rank than unsigned).

This required addition of o3tl::clamp_to_unsigned in o3tl/safeint.hxx.

Change-Id: I0a04a8b32e63ebfeb39f924c4b38520455a6fb38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135309
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-06-02 17:13:17 +02:00
Noel Grandin 9c779279f5 use comphelper::ByteReader in XBufferedStream
to avoid an intermediary buffer

Change-Id: Ic59e701491ac041022ca3e328741f170bb5b7ab6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134842
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-24 16:58:14 +02:00
Noel Grandin 8eabb8839d reserve space in map in ZipFile::readCEN
Change-Id: I4d7764f00b7d05ba5d43a3fb35596f5ec4653da3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134302
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-14 14:44:02 +02:00
Stephan Bergmann bdff0bb77b Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has
just been proven to be non-negative here

Change-Id: I9665e6c2c4c5557f2d4cf1bb646f9fffc7bd7d30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133442
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-04-26 17:04:01 +02:00
Stephan Bergmann 83dd8deed7 loplugin:trivialdestructor (-stdlib=libc++)
That these are only flagged when building against libc++ and not against
libstdc++ is a consequence of the plugin's dependence on implementation details
of the relevant classes, but so be it.

Change-Id: I6b96f81939edab2b8e618aa53c9fe23492edfbbd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131562
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-03-14 22:30:44 +01:00
Noel Grandin 7002caa97e new loplugin:trivialdestructor
look for potentially trivial destructors that can then be elided

Change-Id: I435c251bd4291b5864c20d68f88676faac7c43fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131318
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-03-11 09:06:06 +01:00
Gabor Kelemen 7b5193e2ae Recheck modules [o-r]* with IWYU
See tdf#42949 for motivation

Change-Id: I6b4b05a5e59b256653c4caf5297fffd601b45083
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128845
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2022-01-30 16:10:57 +01:00
Armin Le Grand (Allotropia) 4a0ccb5fec WASM make test file loading work
Change-Id: Ic34104534c3e0e73791cf867bfb2e1246dc79cf8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128653
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2022-01-20 14:27:16 +01:00
Noel Grandin 5c00fadcc9 optimise and simplify ZipOutputEntryInThread
by just using the tempfile service as intended, we can stay
on the "happy path" which means that, on Windows, if there is
sufficient system RAM, the temporary file never even hits
the disk.

Change-Id: I3b27cf09bd40a4cfee01c23273af05860708a16f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128258
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-01-11 07:19:25 +01:00
Noel Grandin a3fa2c3bad Simplify some TempFile service code
Change-Id: Id39be33dcc5aa9378e29c850cb71d3662093ab25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128189
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-01-09 18:02:08 +01:00
Mike Kaganski d0a8d4a973 Prepare for removal of non-const operator[] from Sequence in package
Change-Id: Ib5d7fa143c4c5e3b4862ed4b91acf1e2dfc4d8bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124378
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-30 20:17:13 +02:00
Mike Kaganski 2484de6728 Remove non-const Sequence::begin()/end() in internal code
... to avoid hidden cost of multiple COW checks, because they
call getArray() internally.
This obsoletes [loplugin:sequenceloop].

Also rename toNonConstRange to asNonConstRange, to reflect that
the result is a view of the sequence, not an independent object.

TODO: also drop non-const operator[], but introduce operator[]
in SequenceRange.

Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-15 10:36:36 +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
Mike Kaganski 93e90309b3 Use ZLIB_CONST to avoid const_cast
It is available since 2011 [1]. CentOS 7, which is the baseline,
included zlib 1.2.7, which was released in 2012, and included [1].

[1] https://github.com/madler/zlib/commit/5ab9f47745fe9353291b217f705086b6070575d5,

Change-Id: Ie6cf2e934579620787426d95380f8ff6d6423b7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119627
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-07-31 23:27:25 +02:00
Noel Grandin 95f5c4fb55 getArray->getConstArray in package
so we can avoid the const of making the Sequence singular

Change-Id: I939d573c0f1e7a5d3b09a8589c0fda1e9ea38208
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119739
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-31 18:21:42 +02:00
Noel Grandin 4bf1fbc957 tsan:data race in XBufferedThreadedStream
cannot read from maInUseBuffer without holding the lock

Change-Id: I4244e1132595a18c1a7ab33803e10b6c29684bf9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119707
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-30 17:54:32 +02:00
Noel Grandin 0c3da17e41 pass ZipEnumeration around by value
Change-Id: I8418bd3eb6a8013f55f4283c7d96755d95a60c1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119305
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-21 12:20:23 +02:00
Noel Grandin 0f580560e9 osl::Mutex->std::mutex in StarOfficeSHA1DigestContext
Change-Id: I924796823230151a3edde2ead875cfc5bc5072d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119282
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-20 21:03:38 +02:00
Noel Grandin 0c14226903 osl::Mutex->std::mutex in CorrectSHA1DigestContext
Change-Id: Ia81e8edd84080a2cb750e2dce7b2e8879b66498e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119281
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-20 21:03:16 +02:00
Noel Grandin 9bae1f1ad6 no need to use a pImpl in CorrectSHA1DigestContext
Change-Id: If7404f63833373c5ac2954c4aac129c52582989c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119280
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-20 21:02:52 +02:00
Noel Grandin 966ae2345c osl::Mutex->std::mutex in BlowfishCFB8CipherContext
Change-Id: Id70ec156ab9e06a48a5a2571fc0186bd63b280a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119279
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-20 19:36:59 +02:00
Noel Grandin a4a023f7f4 osl::Mutex->std::mutex in ByteGrabber
Change-Id: I96ea49da6708041ac19e147f192c7e996d44b8ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119276
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-20 19:23:49 +02:00
Noel Grandin 3ffb7efa95 remove some unnecessary OUString::intern
Change-Id: Ia0f41dfc8a00c115ad544b8236d751e6b2dae5ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117577
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-06-21 15:02:53 +02:00
David Blatter 24fad8bf16 fix detection of encrypted zip entries
if a zip entry is encrypted, bit 1 of the flags field is set. previously
bit 1 of the version field was checked. a valid zip with a required version
of e.g. 45 generated a 'file is corrupt' error

see: https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.3.TXT
(sections 4.4.3 and 4.4.4)

Change-Id: I8bba6ead582e6cab55c8449f202807b50befea07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113420
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-04-02 12:51:29 +02:00