481 Commits
Author SHA1 Message Date
Caolán McNamara 5b42ac7163 ReadLine and ReadUniStringLine: stop at the limit in the loop
the two have drifted apart, so check the limit as each character is
read instead of correcting the count afterwards

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Idad62990843d58dfa13a69667295285ba4c7227f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/12715
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit bbb65e562218787fcc6527aa1e3683017f962eca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211278
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-21 13:02:57 +02:00
Julien Nabet 1e0180a814 Revert "tdf#166299 tdf#172587: try to improve encoding detection"
This reverts commit d71b9934b3.

Reason for revert: don't try to tweak too much ICU results

Change-Id: I9f35294376faa5b82729c0072cf66b5fe5f79a7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209285
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-18 16:55:37 +02:00
Julien Nabet d71b9934b3 tdf#166299 tdf#172587: try to improve encoding detection
Instead of selecting the first encoding returned by ucsdet_detectAll
(except the 5 CJK when they have confidence of 10), recalculate
confidence by removing 10 only when one of the 5 CJK encodings then
check each encoding returned by ucsdet_detectAll and select the one with
the max confidence with this new rule.

I also tested this again on tdf#172905, no regression.

Change-Id: I6a8e2b30e8467fefd53c02296484e48ca467c662
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209143
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-16 14:38:56 +02:00
Julien Nabet fb4626933e Related tdf#172905: avoid magic number
Change-Id: I60c22d076f0c2435a07bfc12497499092dfb9d7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208977
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-06 14:56:58 +02:00
Julien Nabet aac1744361 tdf#172905: for some CJK character sets, 10 is the starting point
whereas 0 is the starting point (eg for iso-8859-*)
So don't retain the CJK character sets if they're just at 10
and there's no other character sets

+ add some debug traces to track charsets detected by libicu
and their associated confidence

Change-Id: I7d89d06ffb963143276aff749e7d1a6f7a531cca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208899
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-01 23:14:48 +02:00
Julien Nabet f21643c5fe tdf#171097: add ISO-8859-8-I in encodings map detection
Change-Id: Ib84bd5de4bb3495a0f3339afa0537fd8003d1dc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208971
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-08-01 13:38:07 +02:00
Rene Engelhard edfb978cf6 fix build with older boosts (e.g. 1.83)
after af82f165ca

Change-Id: I2ca4757695b1d01a287d7a4e8d48d22455431d12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200864
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-03-03 22:31:17 +01:00
Mike Kaganski 35871de09d Set encoding in StartReadingUnicodeText
Simplifies some code. It doesn't make sense to set endianness, but
avoid setting encoding.

Change-Id: I3a09fea7381b6c113075b9800b06b307cdaa6d45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200668
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-28 09:49:55 +01:00
Noel Grandin 98174967db SvStream::WriteUniOrByteString should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: If141ba09afe1b04f5d836024975f00e8b20d1447
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200462
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:49:07 +01:00
Noel Grandin d235ca3589 SvStream::ReadUniOrByteString should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: I5b015f12f141a89b176c5a22aeecc4336f0b8f13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200460
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:48:47 +01:00
Noel Grandin 5ad9d928c7 SvStream::WriteUniOrByteChar should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: Ie019e9f7a668b943e418126b14b8bf852a4fa966
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200459
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-27 07:48:36 +01:00
Noel Grandin 4e6f8e76bf SvStream::ReadByteStringLine should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: Icceb067e600140589c329429d12add2ef3d471c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200458
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2026-02-26 20:19:02 +01:00
Noel Grandin 3c5f8e3dea SvFileStream::ReadUniOrByteStringLine should not need to specify encoding
Instead, rely on the stream being set into the correct encoding
during stream initialisation.

Change-Id: I96b6818dd07cf4b83959884bcbe3be2cbf90b476
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200457
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2026-02-26 20:18:50 +01:00
Stephan Bergmann af82f165ca Avoid unspecified behavior when checking for "pointer in range"
...which can easily cause wrong behavior.

(Maybe we can eventually replace the use of Boost here with Standard C++, if
something like
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3234r1.html> "Utility
to check if a pointer is in a given range" ever gets in.)

Change-Id: I9122efdd3272613b27c33a0d7dbc04ad2d6e39e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200454
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-02-26 19:44:18 +01:00
Mike Kaganski 6c89e5a2d2 Use SvStream::DetectEncoding in GetNextChar
... instead of direct use of ucsdet_detect.

Change-Id: If1c523b3b6fd19c2817dfe2cd09e6aa7148de634
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200377
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-26 16:58:03 +01:00
Noel Grandin a9503c4cf8 SvFileStream should not need to specify encoding on per-call basis
Starts a process of converting the call-sites of SvFileStream
to just write data, relying on the stream being set
into the correct encoding somewhere during initialisation.

In this commit, I change WriteByteStringLine to do that.
For most of the call sites, they either:
(a) use the stream encoding explicitly
(b) already set the stream to the encoding being used at the call-site

Only in buildFontMenuName did I need to make the stream explicitly
set the stream encoding.

Also add a utility constructor to SvFileStream to make it easy
to set the stream in the correct mode at open-time.
Ideally a stream should be set into the correct encoding
at open time and never changed.

Change-Id: I57afa74807e15320a176a05d43c94c377dad4561
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200289
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-26 16:57:00 +01:00
Noel Grandin 9ff0df208b fix pointer arithmetic in SvMemoryStream::PutData
after
  commit fa002b6244
  Author: Noel Grandin <noelgrandin@gmail.com>
  Date:   Sat Feb 21 21:00:32 2026 +0200
  fix asan heap-use-after-free

Change-Id: I2ed04d2957089f2e6968ac63b14639e27709295c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200400
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-26 13:50:59 +01:00
Mike Kaganski 55b9d8607b "CharSet" -> "Encoding" in SvStream
Use the correct term. E.g., Unicode charset has different encodings
like UTF-8 and UTF-16, and we mean encoding here.

Change-Id: I65e90b31cda6e39fdb1584b492e6e0b9821865a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200285
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-25 10:33:55 +01:00
Mike Kaganski 610168656a Move encoding detection to SvStream
Allows to avoid similar code in SwIoSystem and SfxObjectShell, and
unifies the code.

Change-Id: I16817f2aea5bdabb9bf3505f2f3c2f697e3106e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200284
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-25 10:33:49 +01:00
Noel Grandin fa002b6244 fix asan heap-use-after-free
Seems like recent font/pdf related changes have exposed a latent
bug(?) in the SvMemoryStream class. Specifically, writing to
SvMemoryStream using a source pointer that points inside the SvMemoryStream
data buffer causes trouble when the buffer is re-allocated.

Make SvMemoryStream tolerant of this, although it is a rather
dodgy use-case.

READ of size 177 at 0x531000155fe7 thread T0
  SvMemoryStream::PutData(void const*, unsigned long) /tools/source/stream/stream.cxx:1578:5
  SvStream::WriteBytes(void const*, unsigned long) /tools/source/stream/stream.cxx:1195:26
  vcl::filter::PDFDocument::WriteCatalogObject(int, vcl::filter::PDFReferenceElement*&) /vcl/source/filter/ipdf/pdfdocument.cxx:577:27

freed by thread T0 here:
  in SvMemoryStream::FreeMemory() /tools/source/stream/stream.cxx:1694:9
  in SvMemoryStream::ReAllocateMemory(long) /tools/source/stream/stream.cxx:1671:9
  in SvMemoryStream::PutData(void const*, unsigned long) /tools/source/stream/stream.cxx:1569:22
  in SvStream::WriteBytes(void const*, unsigned long) /tools/source/stream/stream.cxx:1195:26
  in vcl::filter::PDFDocument::WriteCatalogObject(int, vcl::filter::PDFReferenceElement*&) /vcl/source/filter/ipdf/pdfdocument.cxx:577:27

Change-Id: I2613ed66cec600b7f44e575a56f6a97c0ff3053d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199959
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-02-25 09:12:11 +01:00
Gabor Kelemen c511c65434 tdf#146619 Use more forward declarations in include/tools
Change-Id: Iab2938f82a9fd7ef3334d69c4fd07a9d963a9e24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198237
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
2026-02-01 09:23:01 +01:00
Stephan Bergmann e3ea377f2d Make a virtual function non-inline
...which helps avoid some supposedly spurious -Werror=free-nonheap-object seen
at least with recent GCC 16 trunk,

> In destructor ‘virtual SvLockBytes::~SvLockBytes()’,
>     inlined from ‘void SvRefBase::ReleaseRef()’ at include/tools/ref.hxx:160:36,
>     inlined from ‘tools::SvRef<T>::~SvRef() [with T = writerfilter::rtftok::RTFTokenizer]’ at include/tools/ref.hxx:56:46,
>     inlined from ‘writerfilter::rtftok::RTFLookahead::~RTFLookahead()’ at sw/source/writerfilter/rtftok/rtflookahead.cxx:37:1:
> include/tools/stream.hxx:115:48: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘((tools::SvRef<writerfilter::rtftok::RTFTokenizer>*)this)[1].tools::SvRef<writerfilter::rtftok::RTFTokenizer>::pObj’ with nonzero offset 56 [-Werror=free-nonheap-object]
>   115 |     virtual ~SvLockBytes() override { close(); }
>       |                                                ^

etc.

Change-Id: I26a599f0e3258e6bf6a4d6e63e559b41029862db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197842
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-01-23 08:04:24 +01:00
Caolán McNamara be6015e3c4 cid#1659971 silence Overflowed return value
and

cid#1659699 Overflowed return value
cid#1659759 Overflowed return value
cid#1659922 Overflowed return value
cid#1660190 Overflowed return value
cid#1660286 Overflowed return value
cid#1660457 Overflowed return value

Change-Id: Ie9fffe4994b10ed3d4feb14eaf7950e3f01714ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189927
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2025-08-20 15:08:44 +02:00
Noel Grandin 58b9b2fa7a const up various static locals
Change-Id: I0bbfd1daca973cc158f8d3a60b8df44cd5565f57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187825
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-07-23 15:55:16 +02:00
Mike Kaganski 12c6fc8afa Introduce SvStream::ResetEndianSwap to reset to native endianness
Used in several places; avoids inclusion of osl/endian.h and use of
ifdefs for the task.

Change-Id: I87a7b41ef6d0edc3fee39cc192f7abe09f7e45df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186928
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-06-25 17:22:45 +02:00
Mike Kaganski b42fad8a35 Use ReadLine taking OStringBuffer to reduce allocations
Change-Id: Ib180a1c67346eb6ce8cfbb6549b6e31e1b7911a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186073
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-05-31 16:53:45 +02:00
Arnaud VERSINI e47aebcec5 tools : use constexpr array instead of std::vector
Change-Id: Ifade95457b4b7c614a4ec83857c822d349a9f88d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179444
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Arnaud Versini <arnaud.versini@pm.me>
2024-12-27 16:26:13 +01:00
Noel Grandin c6fa60bdff consistently return -1 in SvFileStream::PutData
for the error case

Just for consistency with the other error cases in PutData/GetData

Change-Id: Ib7fd27f9347021b3063e6eac88fd8038d5f218e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176621
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-15 12:12:54 +01:00
Noel Grandin 246ef0b8ea loplugin:singlevalfields
Change-Id: I4d7b38c90d73a00f4dbc8ad7318fe4573328ed46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166503
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-04-23 11:28:55 +02:00
Noel Grandin 99c857afda loplugin:unusedfields
Change-Id: I43b7a553177bbbdeebe37f7d7e63dfcb2ae70778
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166292
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-04-19 21:26:43 +02:00
Mike Kaganski 2b4094195e Clean up SvStream API a bit
Change-Id: Ic9847185e8f551eeb05715902374d7a9a9032f60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160546
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-12-11 07:10:31 +01:00
Mike Kaganski d88d113c7d Simplify SvStream::WriteDouble
Change-Id: I0ece791b5571d3839c936e104016f53cc3b6d5e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160537
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-12-10 17:08:06 +01:00
Mike Kaganski b4fda935de Keep original error
Fix several SetError implementations, to make sure that original
errors are not rewritten, but OTOH warnings could be replaced by
errors.

Change-Id: Ic5e71b791ff3426ff1144778a610ab77fcbf24d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160530
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-12-10 12:38:17 +01:00
sahil d56b619753 tdf#130924 replace '*printf' with 'SAL_*' logging macros in tools
Change-Id: I9721bfd3783fd6c5d41b2d9a0e8468c583ede0c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156864
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-10-23 15:50:09 +02:00
Mike Kaganski 1155def95b Drop Writer::OutLong
... and use SvStream::WriteNumberAsString, replacing Write[U]Int32AsString

Change-Id: I10e56c532494239ed40ec01b6184dd06db463a0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150193
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-11 09:06:10 +02:00
Mike Kaganski 5fe96b6dce Drop SvStream::WriteCharPtr
WriteOString is a better replacement

Change-Id: Ic431b9aeb98d19fe61cff71360eee555105cc2bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150192
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-10 23:13:32 +02:00
Mike Kaganski f6fa9c4555 Use more *string_view
Change-Id: I1172febd45da4dba006f8495427fe45c6d9b9fa6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150187
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-10 20:09:26 +02: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 3d7b0a6ebb move sanitizing of Size inside GenericTypeSerializer
I cannot see a useful application of a Size that is negative
(at least not in a file format).

Change-Id: I0c5bd8c7d3987a5c7803af2a6ae0543c4a6d7754
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147884
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-28 07:23:23 +00:00
Noel Grandin 6db64ffb84 inline StreamData into SvFileStream
Change-Id: Ib2bfaa903b5c57b7d802afe7928720e6007d54ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147865
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-27 11:34:07 +00:00
Stephan Bergmann 70bcf9e8be Remove support for AIX
As discussed in the mailing list thread starting at
<https://lists.freedesktop.org/archives/libreoffice/2023-January/089808.html>
"Plan to remove dead C++ UNO bridge implementations (bridges/source/cpp_uno/*)",
the bridge implementation at bridges/source/cpp_uno/gcc3_aix_powerpc is
apparently dead and should thus be removed.  However, that was the only bridge
implementation for AIX, which implies that support for the AIX platform as a
whole is dead and should thus be removed.

Change-Id: I96de3f7f97d4fd770ff78256f0ea435383688be9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146057
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-01-27 07:28:16 +00:00
Stephan Bergmann 4280a32579 -Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): tools
(The "clang-format off" in tools/source/misc/json_writer.cxx is necessary
because otherwise the code between the SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP
macros would be ill-formatted in a way that would trigger loplugin:indentation.)

Change-Id: Ic96787865d4c96be07c41f4939893420dfa04046
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142339
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-06 01:13:45 +01:00
Noel Grandin 1ea0ea19f1 tdf#133768 speed up temp file creation
Use DELETE_ON_CLOSE attribute, so we can avoid calling osl_removeFile.
Shaves 5% off the export time.

Change-Id: I4fef8f181ef7a92c4805cc5996c3a17800a22602
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141718
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-24 10:10:54 +02:00
Mike Kaganski e7be4bb5a3 Fix StartWritingUnicodeText
Its comment in include/tools/stream.hxx tells:
  Switch to no endian swapping and write 0xfeff

It was introduced in commit 3c2105e07d
  Author Eike Rathke <er@openoffice.org>
  Date   Fri Dec 22 00:19:05 2000 +0000
    new: read/write Unicode or Bytecode

and included a call to SetEndianSwap( FALSE ). That call was dropped
in commit 8130714148
  Author Noel Grandin <noel@peralex.com>
  Date   Mon Jan 05 08:47:31 2015 +0200
    fdo#84938: replace NUMBERFORMAT_INT_ constants with 'enum class'

(likely by accident).

To simplify the fix, drop redundant m_nEndian: m_isSwap is enough.

Change-Id: Ia9a0fe2d55563e7ba21bd4cf17c4ca999c6feaf7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141521
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-10-22 09:32:54 +02:00
Mike Kaganski f4e7738112 Simplify a bit
Change-Id: Ia983d24c539ab37bcc6457630634142cd5826056
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141399
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-10-16 13:13:15 +02:00
Caolán McNamara 1ad7fe75cc cid#1500491 silence Untrusted loop bound
Change-Id: I508337b8a8482b5aaa056a564a0dfa39cbbb4b56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138943
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-28 17:32:30 +02:00
Luboš Luňák 52e1a6a3e4 use a read-only stream when reading graphic data
EmbeddedObjectRef::GetGraphicStream() creates a writable
SvMemoryStream, read the graphics data into it and then returns
the stream, which will be afterwards used to decode the graphics.
But if the data is broken, incorrect seeking may cause a seek
way past the buffer, and since the stream is writable, it would
be done and cause problems such as running out of memory.
The VersionCompatRead class is one such place that reads size
from the stream and then seeks based on the read data.

Add SvMemoryStream::MakeReadOnly() that will change the stream
to be read-only after the initial read of the data into it.

Change-Id: I1d44aabaf73071a691adafa489e65e4f5e3f021d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137002
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-07-12 18:45:14 +02:00
Noel Grandin f23633aa0a no need to stat a dir when opening a temporary file
it can never be a dir

Change-Id: Ib1c234cb20387cd075a19e13e6656738be88716b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134397
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-16 17:51:02 +02:00
Noel Grandin 3817965ded add SvStream::ReadLine(OStringBuffer... to reduce OString allocation
and use it where possible

Change-Id: I3efc7a642f73661ce606c917c0323ba9948521c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134265
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-13 11:11:27 +02:00
Caolán McNamara 08bbd27e1c ofz: Use-of-uninitialized-value
Change-Id: I41554dec3819efcd8e28f82bb732141c85414e9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131074
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-03-06 15:23:19 +01:00