/source/pt/dictionaries/

imo-6-0'>distro/mimo/mimo-6-0 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/tools/source/stream/stream.cxx
AgeCommit message (Collapse)Author
2024-04-23loplugin:singlevalfieldsNoel Grandin
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-19loplugin:unusedfieldsNoel Grandin
Change-Id: I43b7a553177bbbdeebe37f7d7e63dfcb2ae70778 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166292 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-12-11Clean up SvStream API a bitMike Kaganski
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-10Simplify SvStream::WriteDoubleMike Kaganski
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-10Keep original errorMike Kaganski
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-04-11Drop Writer::OutLongMike Kaganski
... 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-10Drop SvStream::WriteCharPtrMike Kaganski
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-10Use more *string_viewMike Kaganski
Change-Id: I1172febd45da4dba006f8495427fe45c6d9b9fa6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150187 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-11-06-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): toolsStephan Bergmann
(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-10-22Fix StartWritingUnicodeTextMike Kaganski
Its comment in include/tools/stream.hxx tells: Switch to no endian swapping and write 0xfeff It was introduced in commit 3c2105e07d29b2069349e1a54e08463d359f988f 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 8130714148d58dd2bf1ef12dcc6dd6d5838be0d1 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-16Simplify a bitMike Kaganski
Change-Id: Ia983d24c539ab37bcc6457630634142cd5826056 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141399 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-08-28cid#1500491 silence Untrusted loop boundCaolán McNamara
Change-Id: I508337b8a8482b5aaa056a564a0dfa39cbbb4b56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138943 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-07-12use a read-only stream when reading graphic dataLuboš Luňák
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-05-13add SvStream::ReadLine(OStringBuffer... to reduce OString allocationNoel Grandin
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-02-28cid#1500555 try +taint_sanitize instead of -taint_sourceCaolán McNamara
Change-Id: I2a0f9ef243c3f17717afed8809b1e3fbc033c6f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130706 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-02-24cid#1500555 try -taint_source function annotation tag on function bodyCaolán McNamara
Change-Id: Iecc87e118e5c5a85ae40e1ae79348883ea328d8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130482 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-02-23cid#1500555 try -taint_source function annotation tagCaolán McNamara
Change-Id: I237a22968024814d578d387e99ae96b748382e00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130433 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-02-21cid#1500555 silence Untrusted loop boundCaolán McNamara
and others, we're not bothered that the contents of the string might have been constructed using byte swapping Change-Id: I0d0c2e0667bf270e2c15624c59312f3f203bb83c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130246 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-01-10use less SvStream::Flush()Noel Grandin
Flush() turns into a sync() on the device, which is pretty slow. Most of the time all we actually want to do is to flush the internal buffers from the SvStream. So expose the FlushBuffer method and use that where possible. And also means we don't need the mbDontFlushOnClose flag on SvStream any more. Change-Id: Ibe089b88b325f0fdc565200a97ce72cd26b7fcfb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128214 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-12-10Make BOM detection slightly more straightforwardMike Kaganski
Without taking system endianness and current stream endianness into account - just read and check single bytes. Change-Id: I9273d8f403caad7adb5e11cecc04e326919dad1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126595 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-08-11Deduplicate number read/writeMike Kaganski
Change-Id: I58808e208ac8b3406497a4e512ec3372434d2ed3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120246 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-06-19SvMemoryStream::GetSize can be more efficientNoel Grandin
Change-Id: I6d60d6549089e049d730c1000ab7ec592924c685 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117499 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-06-19use more TellEnd()Noel Grandin
which has the potential to be more efficient than STREAM_SEEK_TO_END Change-Id: I64d84632bc4751e07309332c9dff7a02bcd507fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117496 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-27use more string_view in tools/streamNoel Grandin
Change-Id: I2a957cd72d71fea717734488cdb3670e0bcdd6f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114657 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-03-24cid#1474353 experiment to silence Untrusted loop boundCaolán McNamara
the value *is* surely sanity checked here despite coverity's bleating that it has passed through std::min unchanged when it is the min value Change-Id: Ic4f2b718832f88528f842280b4c0e04c4b3a9444 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113031 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-01-20ofz#29691 revert throw SvStreamEOFExceptionCaolán McNamara
reasonably sane code like s.ReadUInt32(a).ReadUInt32(b).ReadUInt32(c).ReadUInt32(d); if (s.good()) // use a, b, c d; stopped working. FWIW on a short read we retain whatever was in the variable before the read, rather than overwrite it with new random data, so sal_uInt32 a(0xdead); s.ReadUInt32(a); assert(s.good() || a == 0xdead); the msoffice ppt/escher/xls/doc filters especially speculatively parse and rely on a variables preinit value in the case of a short read. commit b345a2bab0d6f981049951a86b172ce49ce7d4c2 cid#1470786 Uncaught exception commit 71aec4726a94dcde1169fd293dbecfeb0e840e6d ofz#29528 uncaught exception commit bed03603f6cae264abb9e5b58aa2ab00448d92ff ofz#29414 uncaught exception commit 684885a99a1eb7ad943e9736166d4bb1468663be ofz#29443 uncaught exception commit 93574ac7768d247ed754ecda322e54e4bd447e43 ofz#29251 Abrt commit 413db68d95bd39d34e6a6b81a7c5c9478ced0514 ofz#29152 short read commit f400e883044143f999c460375a293647b4a57244 ofz#29151 short read commit 96ea80a725dfe4ef38993f78917c243f13e3beb5 ofz#29129 Abrt on uncaught exception commit 646a635efe6eecbc3d1dd3a7cbb02a278c6f3be5 ofz#28931 Indirect-leak commit b0e573f18629d28fe3179c12d0d434653f92fc93 ofz#29030 Abrt in xlsfuzzer commit 95407c39168d186ee44e67b1a6a4bcf592c58b84 ofz#28902 uncaught exception commit 45175d655ad3773df1c006182108cf25e87b1091 oss-fuzz: tgafuzzer doesn't pass sanity check commit b82fc702bae9d6190bda1b4818a47cfa197df6d8 oss-fuzz: psdfuzzer doesn't pass sanity check commit e7c76d604a4694e6568bf10c2a06a786f1096319 oss-fuzz: epsfuzzer doesn't pass sanity check commit 901e5e7c9170184e286ea3e46fce406136aa9572 oss-fuzz: xlsfuzzer doesn't pass sanity check commit 127bfab61c297df06fd8e71e709bc4362cb89d21 oss-fuzz: pngfuzzer doesn't pass sanity check commit 77387ae00ae27e3f8bcdf7bccf97fb2db8f196b7 oss-fuzz: mtpfuzzer doesn't pass sanity check commit 974ffa79b0fef4ca76558bb8b16bce84af3aaf6c oss-fuzz: xlsxfuzzer doesn't pass sanity check commit 6d6d104cbb382d0045e1f04b12d268992fa5c624 oss-fuzz: bmpfuzzer doesn't pass sanity check commit a7d1d107ec58d3b00b4019c89edddcff71ca6ff3 oss-fuzz: qpwfuzzer doesn't pass sanity check commit 898993aa62276f59480df8af1da4bad530829b56 oss-fuzz: pcxfuzzer doesn't pass sanity check throw/catch parts of commit 8c9a4ff511a3b1d84a7a6d08a1b153c07f164abb throw exception in SvStream when reading past end of file Change-Id: Ic49c249768b17b64d8e868655dbc05b31906c2e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109621 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-12-18throw exception in SvStream when reading past end of fileNoel
to avoid chasing weird problems where we read past the end of file, which leads to random data in the variable we read into. I expect a couple of possible regressions from this change (1) memory leaks caused by non-exception-safe memory handling. Of which there should not be much because we're pretty good about using smart pointer classes these days. (2) Broken files which used to load, will no longer do so. These will have to be debugged by putting a breakpoint on the SvStreamEOFException constructor, and examining the backtrace to see where we should be catching and ignoring the exception to make the code continue to handle such broken files. Change-Id: I351be031bb083a3484a9a1b650a58892700e6fb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105936 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-12-17simplify checkSeek()Noel Grandin
Change-Id: Ie6e016aa9fe630691ed71154489c63a182a3f8cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107827 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-12-14remove Seek(nCurr) in SvStream::remainingSize()Noel
which slows down some operations, and is unnecessary, since TellEnd() already resets the file pointer. Change-Id: I71a0d7f45074039b890997a730afa1cd1c160886 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107689 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-12-11Adapt the remaining OUString functions to std string_viewStephan Bergmann
...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-10-28tdf#123476 filter: try to detect 0-byte files based on extensionMiklos Vajna
A 0-byte ("empty") pptx file is obviously junk input, so it's not surprising if the catch-all generic_Text filter is chosen to open it in Writer at the end. But we can do better: if we really get an empty file URL with an extension we can recognize, that we can fake the filter type / filter name, so the empty "presentation" opens in Impress, and also a re-save works as expected. This builds on top of commit 8a201be240b6d408d15166be7ffc576b9e123634 (fdo#68903 Import .tsv and .xls plain text files in Calc by default, 2013-10-27), just the new way works for all supported file extensions and also with filters which would not handle empty input (e.g. pptx refuses the import if the ZIP storage is broken). Change-Id: Ie01650a5eb6ca42c35e090133965467b621bb526 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104939 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2020-10-19add tools::Long typedef and use it in toolsNoel
first step to switching long to a 64-bit type on 64-bit windows Change-Id: I640d807426dfe713c7a8984ef560575f8288dbeb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104516 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>